var sidebar_align = 'right';
var content_container_margin = parseInt('350px');
var sidebar_width = parseInt('330px');
how to mod_rewrite
i am working on a website that requires search engine friendly urls.
the urls are currently like this (for example):
I used this tool (
http : //www.domain.com/?Page=Login&Type=Customer
http://www.generateit.net/mod-rewrite/) to generate the following mod_rewrite rule:
So, the rewritten url would look like this (for example):
RewriteRule ^([^-]*)-([^-]*)\. html $ /? Page =$ 1 & Type =$ 2 [ L ]
I run into problem, when i pass only one param into the query string, e.g.
http : //www.domain.com/Login-Customer.html
(where as before i was passing two). www.domain.com/?Page=Browse
When i pass one param, the rewritten url looks odd, e.g. (notice the dash at the end) www.domain.com/Browse-.html
Is there a way to do this properly? For example:
domain.com/?Page=Login&Type=Customer ==> domain.com/Login-Customer.html
domain.com/?Page=Browse ==> domain.com/Browse.html
Thanks for any help, i'm new to this.
If your sites only go one or two levels, just add
RewriteRule ^([^-]*). html $ /? Page =$ 1 [ L ]
... below the other one.
After re-reading what you wrote, I don't see how it could do what you are describing.
Last edited by HostSentry; 07-24-2009 at
Yes, mod_rewrite can do what you are describing. You would need to use two rules within the .htaccess file; the first rule should (IMO) be the rule you already have, and then a second rule for the one part URL (e.g. /Browse.html --> ?Page=Browse where Browse is the variable, not containing the - symbol.)
The url is not re-written when you request
Its the friendly URL which works as a alias for the old url. http://example.com/?Page=Browse
You should actually make sure that the content isn't accesible on the old URL, this can be done by throwing out a 404 if your index.php (or whatever) is requested.
thanks guys, i think i got it.
i only have 2 levels, so i tried this and it's working fine:
So, im i correct to assume that a .htaccess can have multiple rewrite rules?
RewriteEngine On RewriteRule ^([^-]*)-([^-]*). html $ ? Page =$ 1 & Type =$ 2 [ L ] RewriteRule ^([^-]*). html $ ? Page =$ 1 [ L ]
Yup, you are correct.
By OneBinary in forum Programming Discussion
Last Post: 05-17-2005, 11:56 AM
By Sticks in forum Hosting Security and Technology
Last Post: 10-23-2004, 11:27 PM
By Alaire in forum Programming Discussion
Last Post: 01-22-2004, 11:47 AM
By Mr. DJ in forum Hosting Security and Technology
Last Post: 12-24-2003, 10:40 AM
By tbroeker in forum Hosting Security and Technology
Last Post: 10-11-2003, 01:18 AM