![]() |
Mod_rewrite
I'm trying to use mod_rewrite on a site I'm doing. My problem is I want to have a few different rules and I'm not sure how to do them at all *!*
For example, if somebody goes to: Quote:
But I also want if someone goes to: to send them to: Is it possible to have lots of different rules like this or will they all just confuse each other? If someone could point me to a good article on mod_rewrite aswell I'd be grateful :) |
|
That is another probably good place to ask questions, but here's a few places to find answers:
mod_rewrite Cheat Sheet - Cheat Sheets - ILoveJackDaniels.com Easy Mod Rewrite : mod_rewrite tutorial mod_rewrite: A Beginner's Guide to URL Rewriting [Apache & IIS Configuration] I can give you a hint too, you're going to want to use a RewriteCond for the first one you want to do, and a relatively easy RewriteRule for the second. It's possible to have almost as many rules as you want, though it is easy to run into conflicts. The rules cascade though, so it'll go through them one by one in order until it finds one that matches. -m |
Thanks for the links. I've had a look at the tutorials but they dont seem to go into the RewriteCond bit in much detail.
I'm guessing I should be using something along the lines of: Code:
RewriteCond % (HTTP_HOST) |
I'm guessing for the first one something along the lines of
Code:
RewriteCond %{HTTP_HOST} ([^.]+)\.mysite\.com [NC]Code:
RewriteRule ^features/$ features.php [L]Code:
RewriteRule ^([A-Za-z0-9]+)/$ $1.php [L] |
I think I've worked out how to do the first part but apparently I need to enable the dns wildcard on subdomains on my hosting. Anybody got any experience with this?
|
You'll have to update your zone DB file to include something like this:
Code:
*.mysite.com. 14400 IN A 12.345.67.890Code:
ServerAlias *.mysite.com |
Quote:
You cannot just do that with mod_rewrite, you must modify the virtualhosts in the apache config. |
Right, I've enabled the wildcard on subdomains on my host but I'm still having a problem with the .htaccess file.
I have three possible solutions, none of which work properly. Code:
RewriteEngine OnCode:
RewriteEngine OnCode:
RewriteEngine On |
| All times are GMT. The time now is 05:52 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0