mod_rewrite is a URL rewriting module for the Apache web server. It is commonly used for so-called "pretty" URLs because of its ability to redirect on the server side (transparent to clients and their browsers), but also provides the power and flexibility to perform various request handling tasks ...

learn more… | top users | synonyms

5
votes
3answers
19k views

How to remove trailing slashes from URL with .htaccess?

The situation Across the entire domain, we'd like the URLs to hide file extensions and remove trailing slashes, independent of the domain name itself (as in, works on any domain). Sample of our ...
2
votes
1answer
356 views

How do I map a (keyword rich) domain name to an existing website?

I am not experienced technical person, and still learning but will try to explain what I have done so far and what my query is. I have a (hypothetical) domain az-studios.com On that domain I have 3 ...
6
votes
5answers
7k views

How to Remove Extensions From, and Force the Trailing Slash at the End of URLs?

Example of current file structure: example.com/foo.php example.com/bar.html example.com/directory/ example.com/directory/foo.php example.com/directory/bar.html ...
4
votes
1answer
230 views

Redirect non-www to www while preserving protocol

I am aware of the fact that there are tons of questions in this section and in server fault dealing with re-directions from non-www to www URLs. But I couldn't find one dealing with this issue while ...
4
votes
1answer
2k views

mod_rewrite rule for wildcard subdomains?

Sorry if this has been covered, I can't find anything on this specifically. I have wildcard subdomains on (*.mysite.com) I need a mod_rewrite expression for this rewrite: bob.mysite.com => ...
1
vote
1answer
597 views

htaccess and 301 redirects - multiple domains

I have the following which redirects mydomain1.co.uk and mydomain1.com to www.mydomain1.com perfectly. RewriteCond %{HTTP_HOST} !^(.*)\.mydomain1\.com$ [NC] RewriteRule ^(.*)$ ...
5
votes
5answers
14k views

“File does not exist” in apache error log

This is an example of an error in out log file: File does not exist: /var/www/website/female, referer: http://www.website.com/female/dresses/A-Dress-Black "/female" doesn't exist, because we use ...
3
votes
1answer
207 views

Redirect www to non-www using Apache htaccess does not work

I have this in my .htaccess (modified from the default Drupal .htaccess): RewriteCond %{HTTP_HOST} ^www\.website.com\.com$ [NC] RewriteRule ^(.*)$ http://website.com/$1 [L,R=301] In theory this ...
3
votes
1answer
13k views

How to redirect any URL to lowercase URL?

I have this .htaccess files: ErrorDocument 404 /index.html <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^domain\.com [NC] RewriteRule (.*) ...
2
votes
3answers
149 views

Does purposely linking to an invalid URL and then using 301 affect SEO?

On a section of my site, I am currently using .htaccess rewrites to put the ID as part of the URL instead of in the query, like so: RewriteRule ^([a-z_]+)?/?tours/([0-9]+)/(.*) ...
0
votes
1answer
144 views

Switch to https

I'm looking to use an .htaccess file to use mod_rewrite to switch the protocol from http:// to https:// when someone hits my website. For instance, once someone goes to: http://www.mywebsite.com/ ...
3
votes
2answers
432 views

RewriteRule not working for certain URLs

There are a few domains pointing towards the same server, and of course I need them all redirect to only one of them. Redirects work, but only for certain URLs. What works: http://www.domain.com, ...
2
votes
3answers
133 views

How to make parameters look more attractive

I'm making a blog site and instead of the users blogs being called /blog?display=username I would like it to just be a sub domain such as mysite.com/username How would I be able to make the first ...
2
votes
3answers
279 views

How to use .htaccess to show smarter URLs

I'd like to ask how can I call the page www.domain.com/index.php?page=somepage and make the browser show the user in the URL bar the address www.domain.com/somepage/? How do I do that trick?
0
votes
1answer
52 views

Google can no longer fetch pages after successful URL rewrites using an .htaccess file

I tried to rewrite my URLs so they no longer have the .html extension. But when I did this (successfully) Google can no longer crawl my pages when I use "Fetch as Google". Instead, it returns 404 ...
0
votes
1answer
391 views

Force www. on multi domain site and retain http or https

I am using CakePHP which already contains an .htaccess file that looks like: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) ...