.htaccess simple rewrite not working - .htaccess

For some reason this isn't working, am I missing something obvious?
RewriteRule ^(.*)infopopup.html$ /acatalog/infopopup.html

I guess you need to exclude your target file from the RewriteRule because this may cause an infinite loop of rewrites:
RewriteRule ^acatalog/infopopup.html - [L]
RewriteRule ^(.*)infopopup.html$ acatalog/infopopup.html [L]

It was a looping issue, here's what ended up working:
RewriteBase /
RewriteCond %{REQUEST_URI} !/acatalog/.*
RewriteRule ^(.*)infopopup.html$ acatalog/infopopup.html [QSA,L]

Related

Rewrite .htaccess with multiple parameter

i want rewrite /q.php?start=0&co=US&l=AL&s=hotel to /us/al/hotel
I tried this, but I get error - nothing found. and this my htaccess
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /q.php?start=0&co=$1&l=$2&s=$3 [L]
This should work for you
RewriteEngine On
RewriteRule ^([^/]+)/([^/]+)/([^/]+)$ /q.php?start=0&co=$1&l=$2&s=$3 [L]

trying to rewrite url in htaccess

I have url
http://www.url.com/business/index.php?biz=andrewliu
I'm trying to accomplish so it will be
http://www.url.com/business/andrewliu
I tried to have this:
RewriteRule ^/?([a-z0-9_-]+)/?$ /index.php?biz=$1 [L]
or
RewriteRule ^/?([a-z0-9_-]+)/?$ /business/index.php?biz=$1 [L]
doesn't work?
Help me?
Edit:
I have this
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
prior to the rewriterule
That depends in which directory your .htaccess file is.
For the root directory try this one:
RewriteRule ^/?business/([a-zA-Z0-9_-\.]+)/?$ /business/index.php?biz=$1 [L]
If your .htaccess file is in the business directory that of your statments should work fine:
RewriteRule ^/?([a-zA-Z0-9_-\.]+)/?$ /index.php?biz=$1 [L]
RewriteRule ^business/([_0-9a-zA-Z-]+)/?$ business/index.php?b=$1 [L]
It's not clear from your examples whether you want "biz" or "business" or "b". I'm taking a guess that you want "biz", in which case your rule should be:
RewriteRule business/(.*) /index.php?biz=$1 [L]
Or maybe you want:
RewriteRule ([^\/]*)/(.*) /index.php?$1=$2 [L]

.htaccess RewriteRule to get pretty links

I have URLs like:
1) http://www.example.com/?page=2
2) http://www.example.com/my-photos-folder?page=3
Here page number will increase sequentially (page=1, page=2, page=3 .....).
"my-photos-folder" Can be anything like "my-images-folder" or "Nice-photos" etc..
What i would like to get:
1) http://www.example.com/page/2
2) http://www.example.com/my-photos-folder/page/3
My .htaccess has the following rules:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^page\/(.*)$ index.php?page=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?kohana_uri=$1 [QSA,PT,L]
RewriteRule ^$ index.php?kohana_uri=$1 [QSA,PT,L]
RewriteRule ^index.php/(.*) $1 [QSA,R,L]
</IfModule>
Can any expert suggest me what rules i need to add so that my desired outcome will be achived. Thank you in advance.
Add theese lines after the RewriteEngine On line:
RewriteRule ^page\/(.*)$ index.php?page=$1 [L]
RewriteRule ^(.*)\/page\/(.*)$ $1?page=$2 [L]
#develroot
RewriteRule ^page\/(.*)$ index.php?page=$1 [L] //This is working fine for homepage
RewriteRule ^(.*)\/page\/(.*)$ $1?page=$2 [L] //this rule still not working on directory level.
The second one still have issue. Please consider the rules which are already there.[I have updated the question - added your first rule which work fine.]

Joomla .htaccess problem

I am trying to rewrite from
mysite.com/pokerbono/xyz
to
mysite.com/pokerbono.php?id=XYZ
Here is the code I added in the .htaccess:
#### Affiliate Links
RewriteRule ^pokerbono/([a-zA-Z0-9_-]+)$ pokerbono.php?id=$1 [L]
What is wrong with this rule? I tried like 100 variations and always receive a 404.
I tried each and every variation right now I have in my .htaccess the following rows:
RewriteRule ^pokerbono/([a-zA-Z0-9_-]+)$ pokerbono.php?id=$1 [L]
RewriteRule ^pokerbono/([a-zA-Z0-9_-]+)/$ pokerbono.php?id=$1 [L]
RewriteRule ^/pokerbono/([a-zA-Z0-9_-]+)$ pokerbono.php?id=$1 [L]
RewriteRule ^/pokerbono/([a-zA-Z0-9_-]+)/$ pokerbono.php?id=$1 [L]
RewriteRule ^/pokerbono/([a-zA-Z0-9_-]+)$ /pokerbono.php?id=$1 [L]
RewriteRule ^/pokerbono/([a-zA-Z0-9_-]+)/$ /pokerbono.php?id=$1 [L]
Try including slashes on the front:
RewriteRule ^/pokerbono/([a-zA-Z0-9_-]+)$ /pokerbono.php?id=$1 [L]
UPD:
This works in my environment:
RewriteEngine On
RewriteRule ^qwe/([-_a-zA-Z0-9]*)$ qwe.php?id=$1 [L]
I had to disable Multiviews, now it is working fine :)

conditional rules htaccess

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 the complete slug after site.com/. So that i can redirect site.com/category1/subcategory2/subsubcategory3 etc. There can be an unknown amount of subcategories inside a category.
I tried with request_uri but that didn't really work out.
How to do this? Thanks a bunch!
EDIT:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* slug.php?%{QUERY_STRING} [L]
this will pass URL to slug.php
ok, got it. it's simply: deleting the ^/. from the regex. i just figured that means that it has to stop at any / :) but... thx! it works now! :)

Resources