.htaccess

Is it better to use routes or mod_rewrite to forward old URLs?

I recently changed some URLs in my Rails app and am curious if I'm better off using routes + controllers + redirect_to to forward the old URLs, or just use .htaccess with Apache's mod_rewrite? I'm using Apache + Passenger so htaccess files work, but was curious if there was a standard for this sort of thing. FWIW, the URLs were changed...

Display content as root from subdomain

I have a site running on a subdomain of new.site.com and I want to be able to just put something in the .htaccess file that will display the subdomain's content as if it was in the root. Where the site is: new.site.com The url that I want to use: site.com Basically what I want to do is just not move the files from the subdomain to the ...

Using ModRewrite to get rid of extentions

I would like to get rid of all the file extensions on my site. Except when they are on the index i would like it to say nothing... change this foo.com/index.html to this foo.com/ and when the user goes to another page like foo.com/contact-us.html it will be foo.com/contact-us RewriteEngine On RewriteRule ^ this is where i get confused...

how to remove url parameters in htaccess

Hi, I have a codigniter site which does not like added url parameters for example mysite.com/page/value is good but mysite.com/page/value?url=parameters is bad. Google ads campaigns attach url parameter for tracking, I want to get rid of these for the call to Codeigniter. (I know there are several ways to do it in codeigniter but I wa...

URL Structure Parent to Child Relationship With Static Files

Currently I can not show site structure in the url IE www.site.com/parent-page/child-page without creating a subdirectory at the root. Is there an easy way to dynamically create the parent to child relationship other than creating subdirectories? ...

WordPress 404 Errors

I moved a Wordpress website from one server to another and I am now getting 404 errors on everything but the home page. I also checked that the .htaccess file is there and the database contents. They are fine. Not sure what else could be causing this. Any ideas from the community? ...

.htaccess Subdomain Rewrite (not like other questions!)

Hi! I wish to rewrite admin.example.com/test/ to admin.example.com/index.php?site=test. I have done ample research and have yet to be able to do so. Regex is not my thing, anyone have suggestions? (in this particular example, only 'test' is a variable (i.e. 'admin' is constant')) Thanks! ...

.htaccess Conditional Redirect When Pattern Does Not Match

I want to enable my users to enter search queries using a URL like this: www.domain.com/searchterm or with a trailing slash like this: www.domain.com/searchterm/ However, I want to capture certain search terms and redirect them to an actual directory. For example, a query like this: www.domain.com/css/site.css should actually point...

How can I use .htaccess to send distant expiry headers on CSS and JS files?

I want my CSS and JS files to expire in the distant future. Can I do this with .htaccess alone? How would I do it? I know in the future if I change one I will need to force a redownload, something like this should work script.js?v=12 ...

RewriteCond all domains white www

if i have a domain www.domain1.com and www.domain2.com on same folder, how can i get the the www.(domain.com) go to domain.com? hob sombardy can help me :) my ownd idé is RewriteCond %{HTTP_HOST} www.%{HTTP_HOST} RewriteRule (.*) http://%{HTTP_HOST}/$1 [R=301,L] but i don't know about it will work. ...

Adding far future Expires header to .ttf and .otf files

AddType font/opentype .otf AddType font/truetype .ttf AddType font/ie .eot <FilesMatch "\.(otf|eot|ttf|ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" </FilesMatch> I'm trying to add far future Expires header to my font files. This is what I have in my .htaccess file but it doesn't work. A...

.htaccess remove file extension before hashtag

http://freddygonzalez.me/dev/update/index.html#mywork.html How can I use .htaccess to remove the index.html So it could look like this http://freddygonzalez.me/dev/update/#mywork.html Also there may be one conflict.If the user press on the logo they get this http://freddygonzalez.me/dev/update/index.html#index.html So is there a way ...

Is my redirect not removing final slash?

Hello all, I have a site that I don't think my htaccess is implementing 301 redirects properly, I think my problem may be at the application level but I would appreciate it if someone can confirm the following works as I expect it to. Example redirect: http://www.siteic.com/a/b/c/ should go to http://www.siteic.com/a/b/c - however the ...

simple htaccess question

Well this is really simple but I have no clue.. I have a htaccess file in home directory which points all php files to index.php on home directory. RewriteRule ^.*php index.php [L] Now i have created a subdirectories like example.com/mydir/ I want a generic htaccess inside subdirectories that should point example.com/mydir/ to exam...

Perform rewrite even if file at same URL exists (without getting error 500: infinite recursion)

I am trying to get rewriting working in an .htaccess file even when a file in the same location as the requested URL exists. i.e. I want a rewrite of /about/index.html to happen even if there is a file at /about/index.html . Currently I have: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^thehost.example.com$ RewriteCond %{R...

Need to deny all IPs except mine from accessing site and display friendly error.

I need to deny all IPs except mine. I got my outward facing IP from whatismyip.com. Let's assume it is 200.200.200.200 Here is the beginning of my .htaccess ErrorDocument 403 /down.html <Limit GET POST> order deny,allow deny from all allow from 200.200.200.200 </Limit> This works with the denying part - it shows my down.html page. ...

htaccess rewriterule

A fairly basic htaccess question, but I don't use it much, so i have no idea. I want to check if the requested file exists. If it does, forward to one page, and if not forward to another page and pass the requested path as GET. Thanks in advance. ...

.htaccess whit multi domains problem

i have this .htaccess rule RewriteCond %{HTTP_HOST} ^domain1.com RewriteRule (.*) http://www.domain2.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} www.domain1.com RewriteRule (.*) http://www.domain2.com/$1 [R=301,L] and right now i hav this code RewriteCond %{HTTP_HOST} ^www\.(.*) RewriteRule (.*) http://%1/$1 [R=301,L] the problem is ...

.htaccess redirection

Hello I want to have some redirection made by .htaccess file: Some examples mysite.com/accepted -> mysite.com/index.php?type=accepted mysite.com/waiting -> mysite.com/index.php?type=waiting mysite.com/cancelled -> mysite.com/index.php?type=cancelled & mysite.com/edit/2 - > mysite.com/admin.php?edit=2 ETC. for all numbers possible ...

Redirecting from public_html to public_html/new/

I have Joomla site which was upgraded to newest version. New version is in /new/ folder. How can I instruct apache through the .htaccess file to redirect all requests to /new/ folder instead to public_html? ...