I'm trying to make my dynamic URL's into static looking URL's.
This is a typical URL that I now have:
http://www.somedomain.com/design/index.php?p=about
I would like it to be: http://www.somedomain.com/about
So far, I've gotten it to look like this: http://www.somedomain.com/design/about.html
This is the Rewriterule I'm using: RewriteRule ^([a-z]+).html$ index.php?p=$1 [L]
How would I modify it so it would look like this: http://www.somedomain.com/about
?
Thanks for any/all help!!! Very much appreciated!
Rick, you're on the right track. You need to read the Apache rewrite documentation. For your
docroot/.htaccess
start it with:Then generalised version of your rule:
This will rewrite any requests which are for a word string to
index.php
. You need to be aware that the rewrite engine rescans the.htaccess
file if a match has occured so you need to make sure that you don't create a loop. In this case the replacement string has a ".
" in it and the pattern doesn't, so this won't occur, but for more complex cases you may need to 'guard' the rules with one or moreRewriteCond
statements. Again, read the Apache documentation.Using rewrite rules to give 'static' URI is NEVER a good idea.
A few other ideas you can use:
index.php
orindex.html
in it. This way the URL shows http://example.com/about/ and the information you wish can still be displayed as needed.POST
method instead ofGET
methods. This will display as http://example.com/about.php (Note: there is no?
or other parameters behind that.)