mod-rewrite

mod_rewrite: url rewriting plus subdomain (wildcard) rewrite at the same time

i have two rules in my .htaccess file for url rewriting: for subdomain rewriting: xxx.domain.com is internally redirected to file.php?item=xxx RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC] RewriteCond %{HTTP_HOST} ^(www.)?([^.]+).domain.com$ [NC] RewriteRule ^$ /file.php?item=%2 [QSA,nc] ordinary rewriting: RewriteRule ^([A-Za-z0...

htaccess // allow only certain file or folder??

Hi! I'm currently rebuilding my site and I want to make "under construction" page for visitors during that time. My only problem is that I want to user pictures whit it but when I have in my htaccess file this: # Under construction RewriteCond %{REMOTE_HOST} !^xxx\.xxx\.xxx\.xxx RewriteCond %{REQUEST_URI} !/rebuilding\.html$ RewriteRu...

Redirect certain requests if referer not from same page?

I'm quite sure this has been asked before but I can't for the life of me find anything. A client of mine has a number of pages that we closed to the public today. Because image URLs associated with those pages are still valid (the pages must continue to be visible internally for maintenance), the page is obviously still fully visible f...

apache rewrite htaccess

I've been trying things on my server but I can't figure out what's going wrong. As of now, this is the .htaccess I have: Options +FollowSymlinks RewriteEngine on RewriteRule (.*) $1 [NC, L] Instead of rewriting to 'match' it rewrites to 'match'.php Any idea why? ...

If-then-else mod_rewrite for Zend Framework and SSL in .htaccess

I'm trying to automatically redirect for any url that has "checkout" in it to https. Otherwise, if the url is https but doesn't have "checkout", I want to redirect to "http:". Only urls with "checkout" can have https. I need an if-then-else structure. The syntax below doesn't work ... redirects to index.php if there is https in the u...

Mod_rewrite .htm to fake subdirectory

I have a website with a CMS that uses mod_rewrite to make URLs look cleaner. Previously, the clean URLs had the extension .htm, but I want to transition this to them appearing as fake subdirectories, IE: http://www.example.com/pagename/ I have two rewrite rules in place to rewrite both the old scheme and the potential new one: Rewrit...

Why vBulletin .htaccess file contains these repeated statements?

Hi, Please check the attached code. RewriteEngine on # If you are having problems or are using VirtualDocumentRoot, uncomment this line and set it to your vBulletin directory. # RewriteBase /forum/ RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [N...

Htaccess Modify String then Redirect 301

Hi, I'm trying to rewrite the following into htaccess using - redirect 301 redirect "mysite.com/longname/{20 character string}" to "mysite.com/shortname/{10 character string}" basically to redirect the "longname" to "shortname" and cut the "20 character string" to the first 10 characters so when I go to mywebsite.com/longname/aaaaabb...

Following aliases within rewrite conditions

I have the following code: Alias /shared /home/espire/espire/website/shared/www RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule !\.(js|ico|gif|jpg|png|css)$ /home/espire/espire/shared_index.php Which should not rewrite files which actually exists on the server. However, if I'm requ...

How to use mod_Rewrite to check multiple folders for a static file

What are the mod_Rewrite rules for checking multiple folder locations for a given file. For instance, if I have a folder structure of: public/ css/ library1/ css/ library2/ css/ and I want requests to /css/somefile.css to first check the public/css/ directory, then cascade to public/library1/css/ then publ...

Mod_rewriting a query string onto a swf file

I'm attempting to use mod_rewrite to clean up the URL's to a flash video player. First, here is the original URL that I'm trying to rewrite to: library/player.swf?path=path-to-file.flv The above URL works perfectly fine when I access it directly. I have coded the swf to automatically grab the path parameter and play the video. No prob...

mod_rewrite numeral ranges

i'm setting up a directory structure based on dates: 2010/02/01 right now, my rewrite rules look something like this: ([0-9]{4})/([0-9]{2})/([0-9]{2}) I tried limiting the ranges - the month, for instance: ([01-12]{2}) - but that doesn't seem to work. is there a way to do this, or am i making this too complicated and i shouldn't worry...

help me in .htaccess with RewriteRule

now i have set.php?mod=avatar set.php?mod=info now i want make it set/mod this mean useing this RewriteRule ^set/(.*)/?$ set.php?mod=$1 its working but when open it like that set/ its give me 404 error how i can make it in one pharse like that RewriteRule ^set/if this exsist ok if not i want it equal set.php onlly(.*)/?$ set.php?mod...

Rewrite rule with the exception of static content

My current htaccess file looks like this: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f [NC] RewriteCond %{REQUEST_FILENAME} !-d [NC] RewriteRule ^(.*)$ index.php?page=$1 [L,QSA] This works fine for me, however I want to try and reduce server load so I have added this line just below the RewriteEngine On line to stop processing...

Help with mod_rewite rule

I have a rule that will get the extension of every file from the url. I need to match all jpg, gif, png and bmp files. This is for a watermark application. Currently, it only matches jpg and Jpg. Can someone help me match all four extensions? Here is what I currently have so far. RewriteRule ^(.*\.[jJgG].*)$ /test.php?i=$1 ...

Forcing users to access the site with www. and https

I am trying to write an .htaccess rule that appends www. to the domain and s to http if required but I can't seem to find a rule or set of rules that works for each case. The cases are... \https://www.site.com - should just work \http://www.site.com - should go to \https://www.site.com \http://site.com - should go to \https://www.si...

.htacces RewriteRule problem

This is working: RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)/([0-9]*)(/{0,1})$ /main.php?id=$2&il[lang]=$1&page=$3 [L] with this URL: http://localhost/showCategory/590/10 Now I want to work with this too: http://localhost/showCategory/590/transport/10 The rule I tried: RewriteRule ^([a-z]{2}/){0,1}showCate...

RewriteRule problem

RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)/[a-z\-_0-9\+]*/mp/(.*)(/{0,1})$ /main.php?id=$2&il[lang]=$1&$3 [L] RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)/[a-z\-_0-9\+]*/(.*)/mp/(.*)(/{0,1})$ /main.php?id=$2&il[lang]=$1&page=$3&$4 [L] RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)(/{0,1})/[a-z\-_0-9\+]*$ /main.php?id=...

htaccess mod_rewrite

I'm trying to put something with this, whenever I go to a page like: www.site.com/character.php?id=3 I want the mod rewrite to change it to: www.site.com/character/Jim_Carrey Which of course, the ID is the row of the character name... For that kind of example... I've tried to work with it, but don't seem to get most of the productio...

What's wrong with this mod_rewrite statement?

I need to replicate the functionality of mod_alias which I can't use directly because I'm on shared hosting, and Alias statements don't work in .htaccess. What I want to achieve is essentially Alias /manual /www/customer/some_other_dir/manual I am trying mod_rewrite: RewriteRule ^/manual/(.*) /www/customer/some_other_dir/manual/%1?%...