Forum Moderators: phranque
but I want the url to be like:
www.domain.com/123/
I've tried this in my .htaccess file, but it gives me a 500 error.
RewriteEngine on
RewriteRule Pattern Substitution [Flag(s)]
RewriteRule /test/([0-9]+) /test/pagename.php?id=$1
Can someone please help me with this? I have tried so many things to get this to work, but still no luck what so ever.
Welcome to WebmasterWorld!
Here's how this works:
If you want static-appearing URLs like www.domain.com/123/, you must modify your script to produce them. Users and search engine spiders will then pick up these static-appearing URLs, and request them from your site.
Then, when your server receives a request for a static URL, your use mod_rewrite to convert that static URL to the dynamic form needed to call your script.
Mod_rewrite works after a request is received by your server, but before any scripts are invoked and before any content is served. Mod_rewrite cannot be used to change the URLs output by your scripts or those present in static html pages. Therefore, the normal use of mod_rewrite may seem "backwards" from what you expected.
See our Apache forum charter for links to Apache and mod_rewrite resources.
Jim
Options +FollowSymLinks
RewriteEngine on
RewriteRule pagename/(.*)/(.*)/$ /pagename.php?$1=$2
which gives me the url:
www.domain.com/pagename/id/123/
Shouldn't it then be quite easy to get rid of the
pagename/id/
part?
[edited by: jdMorgan at 1:31 pm (utc) on Aug. 13, 2004]
[edit reason] Removed specifics per TOS [/edit]
RewriteRule pagename/(.*)/(.*)/$ /pagename.php?$1=$2which gives me the url:
www.domain.com/pagename/id/123/
Shouldn't it then be quite easy to get rid of the
Yes.
There isn't any reason for the "id" being passed, as it is static.
RewriteRule page/(.*)/$ /page.php?id=$1
Then you can have:
www.domain.com/page/123/