0

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.

GameDevGuru
  • 1,095
  • 2
  • 12
  • 27
  • If there is a dot in url, for example `domain.com/test.php`, How do you plan to process the request. – srain Jul 30 '13 at 01:48
  • @srain I'm trying to get it to show /test in the root directory. If the request is domain.com/test i need it to point to page.php and pass the paramater – GameDevGuru Jul 30 '13 at 01:51

2 Answers2

1

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.

srain
  • 8,944
  • 6
  • 30
  • 42
0

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

Community
  • 1
  • 1
stephenspann
  • 1,823
  • 1
  • 16
  • 31