Questions tagged [rewritecond]
132 questions
1
vote
1 answer
Why HTACCESS RewriteCond %{HTTP_COOKIE} only for php and not working for html?
I was trying to redirect all direct access in my subfolder using this code
RewriteEngine on
RewriteCond %{HTTP_COOKIE} !user_cookie=[^;]
RewriteRule .* http://webhost.org/ [R=301,L]
I realise it was working only for OHP files but not for other…

MyFault
- 11
- 2
1
vote
2 answers
Unsure what this .htaccess set of rules is doing
I've inherited a web application, and in it is the following set of .htaccess rules. It appears to me that they do nothing. Can someone explain what they're doing?
To me, it looks like they're matching only hits to the site root, checking if the…

e_i_pi
- 223
- 1
- 2
- 10
1
vote
0 answers
Referrer Spam from Encoded URLs
I'm trying to prevent referrer spam to a number of websites I run. Then I encountered a lot of lines like this in the log files.
\xd1\x81\xd1\x82\xd1\x80\xd0\xbe\xd0\xb9\xd0\xba\xd0\xb0.kz
I'm currently keeping the referrer spam from appearing in…

GeoffAtkins
- 261
- 2
- 9
1
vote
1 answer
Combining more then 1 Apache rewriterule: virtualhost domain redirect and inputfile redirection
I got stuck on using Apache's RewriteCond and RewriteRule conditions.
I usually don't use them a lot and mostly the documentation provides me enough information to produce a solution by my self.
This time however I got stuck on how to combine more…

Jeroen Maathuis
- 111
- 2
1
vote
1 answer
htaccess rewrite cond for rewriting 404 errors on url's excluded
I have this problem with my .htaccess file.
Google has some URL's indexed I don't want (404 Error) in Webmaster Tools.
I need to rewrite URL's that include --, /- or an ending in - like so:
replace -- with -
remove the - after the /
remove the…

Coach
- 11
- 4
1
vote
2 answers
to set RequestHeader in apache httpd server is not working
I have a requirement, where I need to set the RequestHeader with a value retrieved from the querystring of the URI.
Approach adopted is to write the RewriteCond and ReWriteRule where
the condition is to extract value from %{QUERYSTRING} variable…

Usman Azhar
- 111
- 1
- 1
- 2
1
vote
1 answer
Redirect all the traffic from multiple domains to single domain using htaccess
I have hosted multiple websites on my server all sharing the same code base having one htaccess.
I need something like this.
if (domainname != example.com) redirect to example.com
if there any way of handling this from htaccess
used the…

Harish Ninge Gowda
- 163
- 1
- 2
- 6
1
vote
1 answer
Having issues with my websites htaccess
I recently uploaded a PHP theme on my server. It's working fine on any other sections except my home page. For example, when accessing www.mywebsite.com/anything the theme is working but when on homepage www.mywebsite.com the server's default page…

Nedi
- 11
- 2
1
vote
0 answers
How to provide read access to a folder and its files via htaccess
This is probably trivially easy but after RTFM'ing and trying several things I seem to be a bit stuck...
The current version "appears" to let me access the directory BUT NOT the files via the browser. (Directory it's Files are all 755 (go+rx) - 644…

Ninety Percent
- 11
- 1
1
vote
1 answer
Nginx try_files instead of IFs to accomplish conditional logic
I'm trying to create Nginx vhost configs that will include the equivalent of the Apache htaccess rewrite rules for OpenCart. Here is the orignal:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond…

David Rahrer
- 103
- 8
1
vote
2 answers
How to rewrite URI from root if file doesn't exists in folder?
I have a static folder which is not in my document root. I would like to redirect all the files that are not present in document root, but are present in the static folder. (So if the same file is in two places, the file that is not in the static…

Dimitri Kopriwa
- 177
- 2
- 11
1
vote
1 answer
URL rewriting a specific directory
I want to rewrite the URL when receiving a request that is not a file and either for directory subdir or not a directory at all.
E.g. (!file) && ( (subdir ) | ( !directory ) )
Here's my .htaccess:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond…

lotstolearn
- 21
- 3
1
vote
0 answers
Apache rewrite rule for multiple named virtual hosts with a 'catch all' rule
I have a redirect apache server that I setup for about 30 domains. I want to have all requests get redirected to the main server except for 1 domain.
Basically any domain coming to this server gets forwarded to www.maindomain.com; however, I'd like…

ajburch
- 11
- 2
1
vote
2 answers
VirtualHost Redirect should work with new RewriteBase
Inside the VirtualHost I got this redirect:
RewriteBase /
RewriteCond %{REQUEST_URI} wp-content/uploads/([^.]+\.(jpe?g|gif|bmp|png))$
RewriteRule (.*) http://example.org/$1 [R=301,L,NC]
So the full VirtualHost config is:
…

LeMike
- 179
- 1
- 8
1
vote
2 answers
How to use mod_rewrite to abstract get request with subdomains
I've been at this all day and I thought I had a handle on regular expressions but I'm no longer confident that I do. I've searched all over, read through some horrible guides on mod_rewrite and I'm stumped.
I want to make it so that the…

Satbir Kira
- 113
- 4