Questions tagged [rewritecond]
132 questions
1
vote
1 answer
How to rewrite using htaccess if the file exists in another folder?
We are trying to rewrite to another folder if the file does not exist in the document root, but does exist in the other folder.
The other folder is in a completely different location, which is located using "Alias" in the vhosts.
So, what we have so…

Jack
- 11
- 1
- 2
1
vote
1 answer
RewriteCond always match incorrectly
If I write:
";
?>
SCRIPT_NAME: /index.php
The line above is showed.
I'm using these rewrite lines
RewriteCond %{SCRIPT_NAME} !^/index\.php$
RewriteRule .* http://example.com/404 [L]
I have…

Jvrq
- 75
- 1
- 5
1
vote
1 answer
RewriteCond not matching on my IP when matching on %{REMOTE_ADDR}
I want a mod_rewrite rule not to be executed when traffic is hitting the web-server from internal network. The web server is an apache 2.2
The following RewriteCond is meant to guard the rewrite rule.
RewriteCond %{REMOTE_ADDR}…

noamik
- 163
- 1
- 2
- 10
1
vote
2 answers
Redirect to a URL via htaccess if index.(html|php) doesn't exist
Is it possible to redirect (via a Rewrite Cond?) users to another URL for help if an index.html or index.php file doesn't exist within their home directory?
Thanks
Greg

gregory
- 13
- 1
- 3
1
vote
1 answer
phpMyAdmin rewrite for nginx
I am trying to configure Nginx so that I can access PhpMyAdmin from a subdirectory (aka domain.com/phpmyadmin). The code provided below seems to work for me although I don't want the alias to be /phpmyadmin.
location /phpmyadmin {
root…

Danafer
- 11
- 3
1
vote
1 answer
Prevent redirect loop in mod_rewrite
I'm writing a rule in my htaccess that basically says this:
If the request is for the homepage
And a cookie has not been set
Rewrite the page with /addCookie.php
Then in addCookie.php, we set the cookie and redirect back to the homepage.
This is…

user280381
- 115
- 4
1
vote
1 answer
RewriteCond for multiple files
In htaccess file, RewriteCond for one file bla.php can write so right?
RewriteCond %{REQUEST_FILENAME} !bla.php
Question: how can write RewriteCond for multiple files? for example for 3 files: bla.php, some_bla.php,some_other_bla.php ?

Oto Shavadze
- 113
- 4
1
vote
1 answer
Apache2 - Forward a value from URL param OR cookie, whichever is present
I managed to use apache to strip off a url param and stuff it in a header to be passed on to another server. See this question for reference.
Now I would like to add to this by getting the value for the header from a cookie if it's not present in…

Samo
- 223
- 2
- 10
1
vote
1 answer
Multiple RewriteCond doesn't work
I have in htaccess some like this:
RewriteCond %{HTTP_HOST} !^foo
RewriteCond %{HTTP_HOST} !^bar
RewriteCond %{HTTP_HOST} !^some
RewriteRule ^register,(.*)$ /register.html [R=301,L]
RewriteRule ^offer,(.*)$ /offer.html [R=301,L]
It redirect me if I…

Kamilos
- 235
- 1
- 3
- 9
1
vote
2 answers
Serve PHP page in web root but show contents in subdirectories
I have a web site on a shared hosting server. My directory layout looks like this
/home
/user
/public_html
/pics
/family
There is an index.php file in public_html. I need help writing .htaccess rules that…

MountainRider
- 11
- 2
1
vote
1 answer
Apache mod_rewrite to return a 404 except one directory
I'm trying to configure Apache to return a default 404 page when the / of DocumentRoot is called, except for some directories in that DocumentRoot
Unfortunately, I'm getting a 404 even for the directories that have been specified in the RewriteCond…

Sylvain V
- 21
- 1
- 1
- 2
1
vote
2 answers
htaccess with conditional rewritebase
I have a site (the-tack-shop.co.uk) in which I'm testing my e-commerce framework on. I was trying to test payment using a shared SSL: https://web43.secure-secure.co.uk/the-tack-shop.co.uk/.
I had to change my htaccess file to work with the…

Phil Jackson
- 111
- 1
- 3
1
vote
1 answer
mod_rewrite for specific domains in a mappings file
I have a bunch of domains that I want to go to one domain but various parts of that domain.
# this is what I currently have
RewriteEngine On
RewriteCond %{HTTP_HOST} ^.*\.?foo\.com$ [NC]
RewriteRule ^.*$ ${domainmappings:www.foo.com} [L,R=301]
#…

scott
- 11
- 1
1
vote
2 answers
Lazy Conditional Rule not doing anything! Why?
I am rewriting php generated thumbnails with igly urls into nice ones. instead of img.php?src=bla.jpg&w=200&h=100 the static filenames IMG-file_w200_h100.jpg
Because the rewrite is so complex and involves many variations, only urls starting with…

Sam
- 423
- 3
- 7
- 23
1
vote
2 answers
RewriteCond in .htaccess file gives me bad flag delimiters
I'm upgrading a website and I use this .htaccess file to show maintenance page:
#MAINTENANCE-PAGE REDIRECT
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.0 # Bogus IP address for posting here
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.0 #…

Steven
- 275
- 2
- 9
- 21