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]
Related
To have nice URLs I edited my .htacces file
domain.com/category/content
should be redirected to
domain.com/index.php?category=cat&content=cont
this works fine with this line
RewriteRule ^([^/]*)/([^/]*)$ /index.php?category=$1&content=$2 [L]
but
domain.com/category
should be redirected to
domain.com/index.php?category=cat
to display the contents of the whole category
I'm sure this is easy to solve but it is very confusing to me.
Use 2 rules:
RewriteRule ^([^/]+)/([^/]+)$ /index.php?category=$1&content=$2 [L]
RewriteCond %{REQUEST_URI} !/index.php
RewriteRule ^([^/]+)/?$ /index.php?category=$1 [L]
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.]
I am trying to write rules in .htaccess file.
I Wrote the rule like this:
RewriteCond %{QUERY_STRING} ^id=([0-9]+)&dgid=([0-9]+)$
RewriteRule destination_content-id-(.*)-dgid-(.*)\.htm$ destination_content.html?id=$1&dgid=$2 [L]
restarted the server.
Before it is having the following rule.
RewriteEngine on
# Parse out basename, but remember the fact.
RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes]
# Rewrite to document.phtml if exists...
RewriteCond %{REQUEST_FILENAME}.phtml -f
RewriteRule ^(.*)$ $1.phtml [S=1]
# ...else reverse the previous basename cutout.
RewriteCond %{ENV:WasHTML} ^yes$
RewriteRule ^(.*)$ $1.html
it works fine.
but my rule not working.
Could you please help me in solving the issue.
Thanks,
Srilu
Leave out the RewriteCond (It does not match the RewriteRule).
You'll just need the RewriteRule and I guess you want it to look like this:
RewriteEngine on
RewriteRule destination_content-id-([0-9]+)-dgid-([0-9]+)\.htm$ destination_content.html?id=$1&dgid=$2 [L]
The is my real folder scheme:
ROOT
index.html
news.html
+articles
|-obama.html
|-oil.html
I want some htaccess rule so if people go to domain.com/obama.html the server will fetch the one in the articles folder without redirecting.
If some one goes to domain.com/index.html will still fetchs the one in the articles even if there is an index in the ROOT.
Thanks
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond articles/%{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ articles/$1 [QSA]
RewriteRule .* articles/$1 [L,QSA]
Why don't you just use:
# RewriteRule /obama.html$ /articles/obama.html [L]
RewriteCond %{REQUEST_URI} !^/{index,news}.html$
RewriteRule (.*)$ /articles/$1 [L]
?
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! :)