简体   繁体   中英

Htaccess rewrite root folder request

Is there a possible way to point this:

domain.com/test

to:

domain.com/page.php?a=test

This has been bothering me for a while. Perhaps something like:

RewriteRule ^/(.*)$ page.php?a=$1 [NC] 

I'm trying to point a request like domain.com/test to page.php and pass the parameter.

If you want to map all the request, include domain.com/test.php to domain.com/page.php?a=test.php , you can:

RewriteRule ^/(.*)$ /page.php?a=$1 [NC]

If you only want simply map the request path: domain.com/test to domain.com/page.php?a=test , you should:

RewriteRule ^/([a-zA-Z\-_]*)$ /page.php?a=$1 [NC]

Notice: After map, the url display in browser will still be http://domain.com/test .

Yes, WordPress does this rather successfully with a combination of .htaccess and php... Here's another post that explains it pretty well:

How WordPress permalink system works?

Here's a link that gives the actual WordPress .htaccess code for rewrites:

http://codex.wordpress.org/Using_Permalinks#Creating_and_editing_.28.htaccess.29

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM