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

2
votes
1answer
3k views

mod_rewrite to edit cookies conditionally

Is it possible to use mod_rewrite to modify values in cookies based upon a condition? I am completely new to HTTP, but I have tried a thing or two. The only regex I know is Perl-style, I hope it is ...
0
votes
1answer
376 views

How to use apache mod-rewrite to remove trailing semi-colon on cookie?

We have the following cookie set by a product: Set-Cookie: SSOCookie=T7ngsCmzC2FEq5p2a7o%3D; path=/; domain=.demo.com; We would like to use Apache to remove the trailing ; which doesn't match the ...
0
votes
1answer
582 views

Using mod_rewrite to rewrite URLs with question marks in them

This is probably a mind-numbingly simple question, but for some reason mod_rewrite always manages to completely befuddle me every time I interact with it. A long time ago when I set up my blog and ...
1
vote
1answer
75 views

wrestling with some rewrites for Apache

I have upgraded my gallery2 to gallery3, and notice that some links no longer resolve correctly. Since the proper way is to redirect these with a 301, that is the way I'm going. The following series ...
3
votes
1answer
1k views

When is the leading slash (/) needed in mod_rewrite patterns?

Here is an example from the Apache documentation for enforcing canonical hostnames: RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/?(.*) ...
3
votes
2answers
4k views

htaccess execution order and priority

Can anyone explain to me in what order apache executes .htaccess files residing in different levels of the same path and how the rewrite rules therein are prioritized? For example, why doesn't the ...
2
votes
1answer
2k views

.htaccess - lose the file .html extension

I'm having a bad .htaccess day! I want a user to be able to type the URL mysite.com/about instead of mysite.com/about.html On .htaccess file I have: RewriteEngine On RewriteCond ...
2
votes
1answer
474 views

Htaccess - Rewrite png to php file

I currently use trans.png.php?id=1&campaign=test to track my newsletter campaigns. I want to use trans.png instead as it's the src of an img tag. How can i do this in htaccess? Also is there any ...
0
votes
1answer
154 views

htaccess Rewrite Syntax?

I have a bunch of files with a "NEW-" prefix (e.g. "NEW-index.php"). I need to do a 301 redirect to the corresponding file without the prefix. I've tried a few things but I'm not getting the regex ...
5
votes
2answers
992 views

Redirect/rewrite dynamic URL to sub-domain and create DNS for subdomain

I have created an application in PHP, I would like to re-direct the following URL to corresponding sub-domain. Dynamic URL pattern: http://mydomain.com/mypage.php?user_name=testuser I wish to ...
1
vote
2answers
1k views

How to redirect a website from a folder to the root folder?

I was running a website on a folder (www.example.com/folder). The new version of the website is live and runs on the root folder. How should I redirect users who visit the website using the old URLs ...
0
votes
1answer
1k views

Link to pages on site without .html extension appearing in browser?

I've modified my .htaccess file to allow access to html files without having to include the extension on the end, for example: www.mysite.com/document directs to www.mysite.com/document.html ...
2
votes
1answer
53 views

Finding out what features of regular expressions are supported by mod_rewrite in Apache 1.3?

Is there a particular regular expression engine that is used by mod_rewrite on Apache 1.3? I want to know so I can get a list of supported and non-supported features.
0
votes
2answers
568 views

When using Mod_rewrite does google bot see the original url or the rewritten url?

If i use the bellow code in my .htacess file would google bot (or any other search spiders) see the example.tumblr.com url or would they see the same url as the user ie. example.co.uk/blog ? ...
2
votes
2answers
253 views

How can I test for a URLs existeance before redirecting to it?

I am using Apache's mod_rewrite to redirect mobile users to my mobile site based on their http_user_agent. However not all pages have a mobile equivalent. Also mobile pages end in .html and "full" ...
1
vote
2answers
338 views

WordPress mod_rewrite redirect specific folders

As a new user, I'm not allowed to post more than two hyperlinks here. So I have added a space after every http (ignore them and read as full URLs). System: Debian Etch, Apache 2.2 I have a WordPress ...
1
vote
2answers
1k views

Re-indexing website with clean URL's

So I have a website with URL's like this: http://www.domain.com/profile.php?id=151 I've now cleaned them up with mod_rewrite into this: http://www.domain.com/profile/firstname-lastname/151 I've ...
2
votes
2answers
985 views

apache rewriting url doesn't work(using godaddy hosting)

I'm using a framework to create my website(codeigniter) by default the urls are like this:mysite.com/index.php?/etc/etc/etc. And I'm trying to remove the index.php?, I tried to remove it by doing ...
1
vote
1answer
421 views

403 error with a 301 redirect in .htaccess

I wrote a rewrite rule for one of my pages. This rule is supposed to be for a specific single URL only hence the "static-ness". RewriteRule ^picks/categorizedPicks/126$ ...
1
vote
2answers
1k views

Having mod_rewrite not rewrite requests for a particular directory

I have many forward rules written in my .htaccess file. However, for the requests to a certain directory and its subdirectory, say wordpress, I don't want to use the forward rules. RewriteEngine On ...
1
vote
2answers
3k views

How do I make SEO friendly URLs?

My url is: website.com/profile/?id=24 I want it to be: website.com/profile/kevinlee The ?id=24 will be replaced with the username of the id=24 in the database How do I convert it to that?
5
votes
1answer
10k views

How to pass GET parameters to rewritten URL?

I have an .htaccess rewrite rule like this: RewriteCond %{SCRIPT_FILENME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^search/(.*)$ search.php?q=$1 What this does is, if someone visits ...
2
votes
1answer
101 views

301 redirects mirrored domain

I'm redesigning a site for a friend on my localhost. His old site is an .asp based site and we're replacing it with a WordPress site on LAMP hosting. The old site sits on domain A and also has another ...
3
votes
2answers
341 views

Apache HTTP redirect from a URL list

One of my web applications will be completely replaced by a new system. All URLs will change and thus external links would break. I want to setup Apache httpd to answer with proper 301-redirects to ...
3
votes
2answers
326 views

Create friendly looking URL's with mod rewrite

I want to make the pages on my site more search engine friendly by turning the query strings into meaningful looking page names. For example I have a page that is this: /search.php?c=18 I want it ...
0
votes
1answer
190 views

Redirect domain address to host address with cloaking [duplicate]

Possible Duplicate: What is the best way to redirect my naked domain? I have purchased a domain name with hosting. I would like visitor to my website http://www.smarttelecom.be to see only ...
2
votes
1answer
138 views

Is it possible to check the case on Apache redirects or aliases?

I have a big website (15,000 pages) with a log list of redirects (about 800) that have been used in marketing pieces for years. My Apache server has been running mod_rewrite for the past 10 years or ...
1
vote
1answer
2k views

Apache rewrite to 404 except for matched query

I'm trying to handle logically simple operation, but apache rewrite does not handle my website's query strings requests. I heard it's does not do it eventually. Still cannot understand it's regex ...
3
votes
1answer
176 views

Looking for a step by step guide to URL re-writing with mod_rewrite and other methods

I'm looking for step by step resource about how to rewrite URLs and have a few specific questions. I've read the documentation on mod_rewrite in Apache, but I still find myself a little lost. If ...
5
votes
2answers
428 views

What should I do to notify Google of a switch from “.php” to extension-free URL's?

I've implemented a simple mod-rewrite rule that internally rewrites urls without a file extension (that are not directories) to .php files and removed the .php extension from all our internal links. ...
1
vote
1answer
258 views

Apache: use `foo.html` in preference to `foo/` when both exist

How to get Apache 2.2 to use foo.html in preference to foo/ when both exist? I'm moving a site from dynamic php to static html, while retaining the domain name. I've created a temporary mirror using ...
0
votes
2answers
1k views

.htaccess rule not working without HTTP redirect [R]

I am using the following .htaccess with Wordpress to remove index.php from the visible URL. This works but forces an http redirect so the URL changes in the browser window. If I remove the [R] it no ...
2
votes
1answer
2k views

How do I make SEO friendly URLs from my PHP pages?

I'm pretty new to this and was wondering how to turn my site URLs into SEO friendly URLs using .htaccess and mod_rewrite? My URLs take the form mydomain.com/index.php?pid=1&pagename=Some Page I ...
1
vote
2answers
171 views

Rewrite Issue on index.html

I have index.html on my html_directory on my website also I entered a rule as follows: RewriteRule ^index.html$ newindex.php It seems requests to my site is routing to my index.html file , my ...
2
votes
1answer
697 views

CMS Made Simple: Why does home page return a 404 under www subdomain?

Anyone know why my homepage wont load with the www prefix. Links such as www.mysite.net/about-us will load fine but www.mysite.net returns a 404. Everypage works including the home page if I ...
1
vote
2answers
117 views

Beginner's Apache mod_rewrite - use custom file for website root

Plain and simple - I want user to get main.php file instead of index.php, when he enters website. Such a straightforward task has caused me a lot of pain, and couple of hours googling. Following does ...
1
vote
1answer
1k views

Redirecting not working properly in Firefox 9 (or any older version for that matter)

How do I fix a redirect in Firefox so that it leads my site to another address but with a slash at the end of it? This is my redirect in .htaccess: RewriteCond %{HTTP_HOST} ^test\.mydomain\.com$ ...
0
votes
1answer
397 views

short and friendly URL for affiliate links

This is my first question here on Pro Webmaster... I'm really glad to be here! I believe this question will have a simple answer but I'm starting with htaccess and I want to learn something about ...
2
votes
1answer
85 views

Why is this mod_rewrite redirecting my domain?

I'm trying to redirect all URLs past the "/" of my domain to an old.mysite.com version, but leave the mysite.com itself alone. For example, "mysite.com" -> "mysite.com", but "mysite.com/some-url" -> ...
1
vote
1answer
1k views

Apache rewrite rule for all pages after domain name

I asked this question on stackoverflow.com: http://stackoverflow.com/questions/8466321/apache-rewrite-rule-for-all-pages-after-domain-name Sorry for redirecting, but I wasn't aware of ...
0
votes
1answer
222 views

How to block my images from being displayed by other websites? [duplicate]

Possible Duplicate: How is anti-hotlinking done? I have a lot of images on my site and I don`t want to let other people to use my images on their sites. Is there any way to block the use of ...
1
vote
2answers
2k views

apache domain redirect to subfolder

I have a hosting account with godaddy. Its a linux system running apache. The way they do their setup is your primary domain is the root folder. When you add a subdomain its in a subfolder of the ...
0
votes
2answers
914 views

Apache mod_rewrite rule to convert URL of page, keeping parameters same

I sent out a link in an email that had a typo in the URL. I need to make a quick change for tracking purposes so that any incoming hits to the URL are instead parsed to another URL. From the link ...
3
votes
3answers
222 views

mod rewrite condition !-f being violated

I am using Wolf CMS, which is served by PHP. I want to redirect /index.html to /index.php. I put the following in .htaccess: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / ...
1
vote
1answer
398 views

mod_rewrite to change parts of a URL causes infinite loop error.

I moved my website to a new CMS and some of my URLs look different now, so I want to delete a part of incoming URLs so that links to my page still work properly. The old URL looks like: ...
0
votes
1answer
581 views

Verify 2 cookies with mod_rewrite before serving images

I have the following mod_rewrite rule, which works fine in my Apache 2.x on CentOS 6 Linux machine, but is not complete: RewriteCond %{HTTP_COOKIE} !id RewriteCond %{REQUEST_URI} ...
0
votes
1answer
795 views

Override .htaccess from parent directory

I have a local LAMP stack (without the MySQL. LAP stack? Anyways..) and I am using this as a development environment for a production website. The site is placed in a sub-directory of the Apache2 ...
2
votes
2answers
2k views

Is it possible to force a directory index to display even if an index file exists?

On my Apache server I need to display a directory index of a given folder even if it already contains an index file that has been defined in DirectoryIndex. In this case an index.html file exists, but ...
0
votes
2answers
91 views

How to make mod_rewrite work transparently?

Following is the content of .htaccess file <IfModule mod_rewrite.c> Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ...
0
votes
1answer
579 views

.htaccess 301 rewrite rule not working

I had made the page the-book.html in wordpress site, later changed the name to about-the-book, now i have written the .htaccess file as **RewriteRule ^the-book.html$ ...