GameDevGuru
GameDevGuru

Reputation: 1135

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.

Upvotes: 0

Views: 123

Answers (2)

srain
srain

Reputation: 9082

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.

Upvotes: 1

stephenspann
stephenspann

Reputation: 1843

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

Upvotes: 0

Related Questions