Forum Moderators: phranque
I have a dynamic site that look like this.
[example.com...]
I don't have access to htpd it's a shared hosting, i have to do the rewrite only with .htaccess files.
The url static needs to be as short as possible
Thanks for your help,
Welcome to WebmasterWorld [webmasterworld.com]!
This search [google.com] should get you started nicely.
Jim
I looked a rewrite rule generator of webmaster toolkit, but don't work. Is my host? The rule is wrong? is very difficult to say.
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule en(.*)-(.*)-(.*)\.htm$ /directory/view\.php?site=$1&bn=$2&key=$3
I have place a .htaccess file in main directory with this rule and didn't work.
Suggestions?
There is an error in that code. Do not "escape" periods in the substitution string by preceding them with "\". Only periods in the pattern should be escaped:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule en(.*)-(.*)-(.*)\.htm$ /directory/vie[b]w.p[/b]hp?site=$1&bn=$2&key=$3
I would suggest the following changes, but they are not needed for the code to work. They are only minor improvements:
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule en([b][^-]*)-([^-]*)-([^.]*[/b])\.htm$ /directory/view.php?site=$1&bn=$2&key=$3 [b][L][/b]
Ref:
Apache mod_rewrite documentation [httpd.apache.org]
Regular Expressions tutorial [etext.lib.virginia.edu]
Jim
When I go to url that needs to be rewrited i obtain the url unchanged.
So, if you request "http://www.example.com/enAA-BB-CC.htm" from your server, you do not get the content you expect from "http://www.example.com/directory/view.php?site=AA&bn=BB&key=CC"?
Understand that mod_rewrite can only do this function - It cannot change the links that your script outputs. If you wish to change those links, you will have to modify your script.
Jim