mod-rewrite

Rewrite URLs for a website in a subdirectory

Hello guys! I'm developing a website on localhost using XAMPP under Windows 7. The website URL is http://localhost/lyrics. How can I enable url rewriting for that subdirectory? I tried with the code below but it didn't work. RewriteEngine On RewriteBase /lyrics Thanks in advance. ...

mod_rewrite replace all instances of ampersand with %26 for later

Hey there! I want to simply not use ampersand in my URL so I can pass ampersands further down into my system when a file is requested. The problem is Apache deals with it differently. I don't know how I already rewrite the requested file to index.php?url=$1 so I can see what it was, but if it has an ampersand in there, it can't continu...

mod_rewrite RewriteCond based on Last-modified? (.htaccess)

I know that we can easily base a RewriteCond on any http request header. But can we check (some of) the response headers that are going to be sent? In particular, the Last-modified one? I want to rewrite a url only when the Last-modified date is older than 30 minutes and I'm trying to avoid the overhead of delegating that check to a php...

Passing varible types though mod-rewrite

Hello i am having a issue with htaccess mod_rewrite, maybe someone here could point in the the right direction. my site has 1 main file [index.php] all the navigation is done by passing vars in the url string eg index.php?page=about this is working ok with my .htaccess [below] domain.com/about some of the pages have a second variabl...

.htaccess and rewrite of URL

Need help with .htaccess - not able to get what i want... Ugly URL - http://www.onnlist.com/punerealestate.jsp?section=realestate&file=pune Want Better URL (such as) - mysite/realestate/pune/punerealestate.html here is my latest .htacess file - of course this does not work - Options +FollowSymlinks RewriteEngine on RewriteRule ^p...

redirect from subdomain to domain + .htaccess

Hello friends, Is is possible that i can configure RewriteRule for more then one domain. Like my requirement is My current domain name www.maindomain.com and let say i have three domian and subdomain the subdomain url is example1.maindomain.com example2.maindomain.com example3.maindomain.com Now i want when ever user try to access ...

mod_rewrite noobie question

So, i've got this Zend style frontcontroller set up. Basically it just redirects every url back to index. The urls are in the form of /controller/view/ + [additional parameters] I would like to create some shortcuts in the following form: RewriteRule ^home /home/index RewriteRule ^products /products/view RewriteRule .* index.php Ho...

Cakephp change URL behaviour

Hi, We are developing a site using CakePHP. We have a windows IIS server (shared hosting) with PHP5, that does not support .htaccess or mod_rewrite but still we have the site up and running and developed a lot of things. The current URL structure is something like this: mydomain/index.php/user/add We want to change this to something l...

How do I redirect incoming requests from domain.com to www.domain.com via HTTP and HTTPS using .htaccess?

I have the script: RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] Rewrite rule to redirect /old to /new RewriteCond %{REQUEST_URI} ^/old$ RewriteRule . /new [L,R=301] Which will redirect http://example.com to http://www.example.com, but would like this script to work the same i...

Problem with URL rewriting for same .php page

Hello, I'm having some issues with a mod_rewrite rule. I have to make 2 types of links (the first one is for the artists that have an album, the second one is the for the ones that don't): 1) /lyrics/artist-name/album-name/song-name.php 2) /lyrics/artist-name/song-name.php My code looks like this: RewriteRule ^lyrics/(.*)/(.*)/(.*).ph...

.htaccess mod_rewrite on root directory but need it to skip all other directories

Here is the directory outline: / /css /js /admin /config /etc... So this is what I would like: / <-- Mod re-write for this directory only, skip the rest /css /js /admin /config /etc... .htaccess file: # Turn rewrite engine on RewriteEngine On # Set the base path RewriteBase / # now the rewriting rules Rew...

Force SSL/HTTPS with Zend Framework and mod_rewrite

I have a Zend Framework application that I want to force into HTTPS using mod_rewrite. I am pretty lost when it comes to mod_rewrite. Here is my current .htaccess file in the root of my application. RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-s RewriteCond %{...

How to use mod_rewrite to map to a different domain and preserve the original

For example: www.example.com and subdomain.mydomain.com are on the same server. When I put example.com in the address bar, I want it to serve the pages from subdomain.mydomain.com, but still show as example.com in the browser. So, if the old URL was: subdomain.mydomain.com/this/stuff?is_cool=yes the new url would be www.example.co...

How do you combine these 2 .htaccess RewriteRules into one?

Ok I have another question and I'm a beginner at this. I have this RewriteRule, it redirects the query correctly but doesn't allow me to use the other directories: RewriteRule ^([0-9A-Za-z]+)/?$ /query.php?id=$1 [L] and now this RewriteRule to skip all these directories but now the rule above needs to be commented out for this to wor...

Htaccess Querystring rewrite

I have URLs like /?test that I want to rewrite to /page.php?page=test I tried like this but for some reason it doesn't work. RewriteRule ^\?([a-z0-9\-\+]{3,20})/?$ /page.php?page=$1 [NC,QSA] What am I doing wrong? ...

Rewrite rule for "site down" pages

I was trying to install this .htaccess to notify my users of site maintenance. It seems the first [L] isn't working and the second rewrite is doing everything. How do you guys do site maintenance messages? RewriteEngine on RewriteRule ^s/down$ index.html [L] RewriteRule ^(.*)$ http://metaward.com/s/down [R=302,L] ...

Replace ? in request with RewriteRule

Hi, I'm trying to make site.com/link?p=2 give $_GET['p']==2 even though i've already made site.com/link rewrite to site.com/index.php?page=link So, i'm trying to replace site.com/link?p=2 with site.com/link&p=2 RewriteEngine on RewriteRule (.*)\?(.*) $1\&$2 RewriteCond %{REQUEST_URI} !\....$ RewriteRule ^(.*)$ /index.php?p=$1 ...

mod_rewrite: setting GET depending on HTTP_HOST

Hi guys, I recently discovered the power of the mod_rewrite module and I need some help with it. Say I have a website which has two domain names mapping to the same host... example.com example.net And I would like to set a GET var depending on the the HTTP_HOST (i.e. .com OR .net ?) ... /index.php?lang=en /index.php?lang=es Howev...

htaccess directory

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^admin/([^/]+)/([^/]+).php website.com/admin/index.php?route=$1/$2 [NS] RewriteRule ^modules/([^/]+)/([^/]+).php website.com/admin/index.php?route=$1/$2 [NS] the above works for when you login. it goes to /admin/modules/catalog but when you click on a l...

Rewrite to a new domain? with url query? not working. :( help

I have this rewrite rule... Redirect all initial request from world.example.com to web.example.com RewriteCond %{HTTP_HOST} ^world\.example\.com$ [NC] RewriteCond %{HTTP_HOST} !^$ RewriteCond %{SERVER_PORT} !^80$ RewriteRule ^(.*)$ https://web.example.com$1 [R=301,L] Which works great. But, some of my applications has... https://wor...