mod-rewrite

htaccess rewrite

I would like to rewrite /anything.anyextension into /?post=anything. eg: /this-is-a-post.php into /?post=this-is-a-post or /this-is-a-post.html into /?post=this-is-a-post or even /this-is-a-post/ into /?post=this-is-a-post I tried RewriteRule ^([a-zA-Z0-9_-]+)(|/|\.[a-z]{3,4})$ ?$1 [L] but it doesn't work. Any help appreciated. ...

RewriteEngine: subdomain to index.php, how?

Days later I asked about redirecting dynamic directories to index.php, and I got this code that works perfect (it's the only code I have in .htaccess): RewriteEngine On RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule (.*) index.php This translates urls like http://mydomain.example/dynamicdir/ to http:...

How do I remove a variable name from a URL using htaccess?

So basically I want users to be able to go to my website with a URL of something like /45678, instead of having to use /?p=45678, so really I just want to remove the variable name. I've tried using mod_rewrite, but it seems that is only for removing the name when the page is visited. Thanks for the help, -Tom Update: Here is the curre...

Recursive loop in my .htaccess

Hi all apache experts, I have a problem adding a default rewrite php and html requests to my apache .htaccess. The idea is to set up templates for the content on my site, specifying that the content in a folder uses a specific template. It works fine for html, image and other resources; requests are rewritten to the template nicely. Bu...

Rewrite rule on multiple variables using Apache mod_rewrite

Hi, I would like to know how can I rewrite www.site.com?lang=lv&type=1&mode=2 into www.site.com/lv/1/2 using Apache mod_rewrite options. ...

Making pretty permalinks work in WAMP

I am not able to switch to pretty permalinks in WAMP. Changing to any form other than default gives 404 error. I have switched on the rewrite_module in Apache. I googled the problem and found that following changes should be made to httpd.conf file. My httpd.conf file stands as <Directory /> Options Indexes FollowSymLinks AllowO...

What is wrong with the mod-rewrite regex?

I am trying to rewrite tagged.php?flag=parameter&page=1 into /parameter/?page=1 So I am using: RewriteRule Hotties/?(.*) tagged.php?flag=parameter&page=$1 However the result I am getting is: /parameter/?page= Which is the "1". I am not sure what is missing. Clearly the issue is with the (.) and the "=" but I am not sure wha...

mod rewrite code passes Lyxx syntax checker but fails on execution?

Well I only have 2 things going on here RewriteEngine on #part 1. if testdir/something is typed in # then go to testdir?id=something RewriteCond %{REQUEST_URI} home/testdir RewriteRule home/testdir/(.*)$ /home/testdir?page=$1 [L] #part 2. Send everything else to the homepage unless # it is a file that exists, or if the re...

mod_rewrite question

How to rewrite rule using mod_rewrite - so all links which starts with "/share/" like this one "www.domain.com/share/XXX/YYY/ZZ..." will be showed as emtpy page? I tried this RewriteCond %{REQUEST_URI} ^/share/(.*) RewriteRule (.*) empty.html [L] But it doesn't seem to work Please help ...

Htaccess rule to move entire site into a folder?

I have two folders in httpdocs site_v1 site_v2 I would like to redirect the entire domain to site_v2 but also to keep reference to this so this would work www.example.com -> gets into site_v2 www.example.com/site_v1/ -> gets into site_v1 www.example.com/site_v2/ -> gets into site_v2 How would be the htaccess directives for this ki...

Cakephp htaccess mod_rewrite on GoDaddy

Hi All: I have a godaddy hosting account and having some problems with routing. The files are under /cakephp under the default /html folder. The full url is still showing instead of the desired www[dot]domain[dot]org Please help. The current setup /cakephp/.htaccess RewriteEngine on RewriteBase /cakephp RewriteRule ^$ ap...

htaccess ForceType application/x-httpd-php....

This is probably going to seem a little strange but we are using <Files "*"> ForceType application/x-httpd-php </Files> Which of course forces all files to give html/php headers.. The reason I am doing this way is because were using a bunch of extention'less php files. I know there is plenty more efficient ways of doing this but my b...

How to create a search , search engine friendly ( mod_rewrite htaccess )

I want to know if it's possible to create a GET form that has as action "search.php?what=bla bla" and in the url bar it shows "search/bla bla" . Then I can handle the search file and explode the search terms, but what is the rewrite rule? ...

mod_rewrite to transform old request urll into new one...

.hello - i need to transform old url requests to fit into the new sites content; ie 'art-consultancy' used to be 'consultancy' so how can i grab 'consultancy' urls and transform them into 'art-consultancy' MY RULE if ^consultancy$ MAKE ^art-consultancy$ and continue to the rules below... RewriteRule ^art-consultancy$ consultancy-02.ph...

RewriteRule question

RewriteRule ^foo-bar-([0-9]+)-([a-z]+)-([a-z-+]+)/$ index.php?a[]=&b=$1&c=$2&d=$3&e=$4&f=$5 [L,NC] how could i put the last parameter from rule to not be required without to add two lines and in first one to remove it, then in second to remain..? so, rule to be in one line but to have two option to acees url like: /foo-bar-2-steps/ ...

Variable in htaccess, RewriteRule question

How could i use a RewriteRule accesing a variable? If i have: SetEnv MY_VAR (a|b|c) RewriteRule ^%{ENV:MY_VAR}$ index.php?s=$1 [L,QSA] RewriteRule ^%{ENV:MY_VAR}-some-one$ index.php?s=$1 [L,QSA] I have these examples but doesn`t work. Later edit Ok Tim, thank you for the answer. Let say that i have: RewriteRule ^(skoda|bmw|merce...

PHP - Maintaining session when redirecting from HTTP to HTTPS?

Hi, I'm working on a simple shopping cart. When the user clicks checkout the URL changes from HTTP to HTTPS. Unfortunately the session does not appear to carry over and I get errors about $_SESSION['cart'] (where I hold the info) not existing. I tried using mod_rewrite to redirect all HTTP to HTTPS so that the session would all be on H...

how to use a rewrite rule to test the date in a cookie?

I found out that you cannot use a RewriteCond backreference as a pattern condition in the next Rewrite Cond... What I have looks right, but Tim is correct in the comment bellow... This is still passing when we are beyond the expiration date saved in the cookie. Any ideas on how to actually test the value instead of the existence? Rewr...

complex mod_rewrite. Any idea ?

Hello everyone, I want to : - switch from http to https if http is used - redirect the subdomain to index?o=subdomain except www - redirection the subdirectory to index?u=user Example : http://www.mydomain.com will be redirected to https://www.mydomain.com http://subdomain.mydomain.com will be redirected to https://www.mydomain.com/in...

Help with .htaccess

Hello I need help with .htaccess I was using RewriteCond %{REQUEST_URI} !^/unsubscribe(/.*)?$ [NC] that to make a folder load without affecting of RewriteRule ^([0-9]+) view.php?id=$1 [NC] I want rewrite the rule to make a folder independent without doing of other rules into that folder Current code to do so is : RewriteCond %{REQUE...