.htaccess

How to use RewriteBase in .htaccess to rewrite img tags?

I guess I don't understand RewriteBase. I have a (drupal) site built on my dev server and everything works perfectly. I created a fake URL for it in my own apache and hosts file, so I get to my local version with "local-examplesite.com". Eventually it will live at www.examplesite.com, but I want to put up a draft with a temp URL at my...

conditional rules htaccess

hi, Currently, my .htaccess file looks like htis: IndexIgnore */* RewriteEngine on RewriteRule ^add /add.php RewriteRule ^add/$ add.php RewriteRule ^sitemap.xml /xmlsitemap.php RewriteRule ^([^/\.]+)$ /index.php?slug=$1 RewriteRule ^([^/\.]+)/$ /index.php?slug=$1 It works fine for links as: site.com/category/ However, i would like t...

Problems redirecting old domain to new with Apache and htaccess

My homepage is located at www.nazgulled.net and I bought a new domain which is www.ricardoamaral.net. Both these domains point to the same exact server. I'm having two problems with the redirection, my current code is this: RewriteCond %{HTTP_HOST} ^(www\.)?nazgulled\.net [NC] RewriteRule ^(.*)$ http://www.ricardoamaral.net/$1 [L] Fo...

Wildcard subdomains with GoDaddy giving me 404 error

I have a hosting account with GoDaddy and I enabled wildcard subdomains by adding an A Record pointing to the IP Address. However when I try opening abc.mydomain.com, I get a 404 error. I searched the web and am doubting whether I need a .htaccess file. That file does not exist in my root folder. Can someone please guide me how to config...

How to create path redirections

I want to create internal path redirections like in Wordpress e.g. if i have a post (having permalink = 'hello-world') but still if I type 'http://localhost/hello/', I get redirected to 'http://localhost/hello-world' So what code do i use to automatically go to that page with that correct URI, i.e. change the URI that gets displayed in...

how to control charset of directory listing via .htaccess?

Hi all, I've enabled directory listing of a folder under public_html, by adding: Options +Indexes in the .htaccess file. However, some files are not listed correctly by default, as some filenames are in Chinese (UTF-8 encoded). I can see the filenames if the change the browser's charset encoding to UTF-8. How can I let the browser ...

Handling subdomains and https with .htaccess

In the .htaccess example below, if someone types in a URL like the following... http://mysite.com/ricks-motorcycles ...it will automatically load the page from x.com's subdirectory under public_html called "ricks-motorcycles". This technique is called Proxy Throughput. RewriteEngine On RewriteRule ^ricks-motorcycles/(.*)$ http://x.co...

How can I use .htaccess to automatically chmod a folder?

I'm looking at this article http://www.jwrmedia.com/lessons/htaccess/automatic-chmod So, I want more details about this method. Thanks. ...

htaccess url rewrite help

I have the following rewrite URL: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Rewrite all other URLs RewriteRule ^(.*)$ index.php?page=$1 [PT,L] Now I want to add an exception, that if the URL is something like mysite.com/abc it should ignore it and all things inside it also. mysite.com/abc/dfgs also sh...

How can I deny all but one directory name with .htaccess?

I have this .htaccess file where I prevent users from physically accessing files from the browser (where they should only be loaded through the system) Options -Indexes Order deny,allow deny from all I have one problem though, sometimes I load files via AJAX and there I get 403 Forbidden. I have little experience with apache's mod_acc...

How to change base dir with htaccess

I have my whole project in directory document_root and I need to redirect there. I've made simple rewrite rule RewriteEngine on RewriteRule ^(.*)$ document_root/$1 [L] which works just fine if I have http://someurl.com/?foo=bar but when I do http://someurl.com/index.php?foo=bar then it is redirected to the document_root versio...

how to log which page was "not found"? (Trying custom error page with htaccess, php, http_referer)

Hi I was just wondering how to get the link of the webpage which was not found on my website. With following .htaccess code, when a non-existing page is requested, user is redirected to my_404.php. Options -Indexes ErrorDocument 404 http://mysite.com/my_404.php If I have to track down what was the link of the page, which was not ...

htaccess mod_rewrite with dynamic parameters

Hello! I am new to mod_rewrite. I am trying to forward a URL to another one, but I cannot get it to work. Say I want to forward this URL: /cansas.php?m=2&id=2-0-0-0&sid=cansas to /cansas-is-good-for-you and let the header respond with a 301, or just update the URL through [R]. I have this in my .htaccess: Options +FollowSymlinks ...

.htaccess Wildcard Subdomains

I'm trying to implement a solution using .htaccess and wildcard subdomains so that http://subdomain.example.com is mapped to http://example.com/index.php/accounts/subdomain/. My rules look something like: RewriteCond %{HTTP_HOST} !www.example.com [NC] RewriteCond %{HTTP_HOST} ^(www.)?([a-z0-9-]+).example.com [NC] RewriteRule ^(.*/) /in...

htaccess redirect append query string?

I have an htaccess redirect that needs to forward the query string to the new URL, but it's getting dropped after the redirect. Can someone tell me what's wrong? RewriteRule ^services/agents.*$ https://services.example.com/agents/ [R=301,L,QSA] ...

Remove trailing slashes

Hello, I'd like to work with pages without trailing slashes. So now I want my URL's with an trailing slash to redirect (using .htaccess) to the same URL without the trailing slash. I got two .htaccess files: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule (.*) public/$1 </IfModule> And one in my public folder: Directory...

Why does a hyphen in a RewriteRule break when in a sub-folder

I have a bunch of RewriteRules in .htaccess for SEO purposes. Sample... RewriteEngine On RewriteRule ^signup$ /signup.php RewriteRule ^account$ /account.php RewriteRule ^logout$ /logout.php RewriteRule ^login$ /login.php RewriteRule ^recent-questions$ /recent.php RewriteRule ^popular-questions$ /popular.php ... ... (more similar stuff...

htaccess code to remove extension AND add+force trailing slash?

I'm trying to put together some htaccess code that will turn example.com/filename.php into example.com/filename/ (and force the slash) - I've tried varous approaches, but each hasn't worked quite right, from 500 errors on subfolders to issues with the trailing slash, etc... Please help! ...

redirect 301 question

Hi! We just switched to our new website redesign. We have a copy of the previous one in a folder "v1" and the new one is in "v2". I play with 2 .htaccess files. The file are organised as such: root L .htaccess (1) L v1 L v2 L .htaccess (2) .htaccess 1 does 2 things: remove the www out of the URI redirects all requests to v2/...

mod_rewrite based on ip

Hi, I'd like to implement mod_rewrite to put my site into maintance. Basically all ips except a handful we specify would be forwarded to a static html page. Please can someone help with this rule. Also is there a way to turn this on and off easily without editting the htaccess file? Thanks, Josh ...