When i click on a link it should redirect to
for ex; www.domain.com/demo/item.php?item=abc&id=3
but in url it should show as www.domain.com/demo/abc/3
im Using
<IfModule mod_rewrite.c>
Options +SymlinksIfOwnerMatches
RewriteEngine on
RewriteRule ^demo/(.+) demo/item.php?item=$1&id=$2 [NC,L]
Please help
You can try with this one, it will not redirect your URL but if you execute your URL (www.domain.com/demo/abc/3) it will be work.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^demo/([0-9a-zA-Z\s_]+)/([0-9]+)(/?)$ demo/item.php?item=$1&id=$2 [NC,L]
You could try like this after adding the rewritebase directive
RewriteEngine on
RewriteBase /
RewriteRule ^demo/([0-9a-zA-Z\s_]+)/([0-9]+)(/?)$ demo/item.php?item=$1&id=$2 [NC,L]
Related
How can i redirect from www.example.com/dietitian/reema.verma.3 to www.example.com/dietitian/#/3 ? Please help.
Options +FollowSymLinks
RewriteEngine On
Redirect www.example.com/dietitian/reema.verma.3 www.example.com/dietitian/#/3
You can only match REQUEST_URI using RewriteRule or Redirect.
Use this rule:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^/?(dietitian)/.+\.(\d+)/?$ /project/$1/#/$2 [L,NC,NE,R=301]
I like to redirect all pages under olddomain.com/subdirectory/ to be redirected to newdomain.com?
The newdomain.com site has a new URL structure, so I want every page under the olddomain.com/subdirectory/urls to be redirected to the newdomain.com homepage.
I tried below code.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^olddomain.com/subdirectory/$ [NC]
RewriteRule ^(.*)$ http://newdomain.com [R=301,L]
</IfModule>
But its redirecting with existing url like http://newdomain.com//url and its through 404 error.
Any help highly appreciated. Thanks
You can use the following rule :
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^subdir/(.*)$ http://newdomain.com/ [R=301,L]
</IfModule>
Below is the code which i use to url rewrite in our .htaccess file
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule pages/(.*)/? /page/index.php?name=$1 [NC,L]
from the above code if the url is www.example.com/pages/2 then actually it goes to url www.example.com/page/index.php?name=2
but also i want something like this : if a page request is www.example.com/pages/2/user/rahul then it should also go to same url www.example.com/page/index.php?name=2&user=rahul
so doing the above thing i did something like this :
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule pages/(.*)/? /page/index.php?name=$1 [NC,L]
RewriteRule pages/(.*)/user/(.*)/? /page/index.php?name=$1&user=$2 [NC,L]
but it does't work how i want.
Try :
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^pages/([^/]+)/user/([^/]+)/?$ /page/index.php?name=$1&user=$2 [NC,L]
RewriteRule ^pages/([^/]+)/?$ /page/index.php?name=$1 [NC,L]
I'm trying to redirect a folder to a file.
I want to redirect:
www.mysite.com/category/customername
AND
www.mysite.com/category/customername/
TO
www.mysite.com/category.php?customer=customername
This is working, but "customer" become "customername.php" and not "customer"
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^category/(.*)$ category.php?customer=$1 [L]
How could i remove ".php" via .htaccess?
Thank you!
You can use:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^category/([\s\w-]+)/?$ category.php?customer=$1 [L,NC,QSA]
Thank you anubhava, i have do a dynamic rule:
RewriteRule ^(.+[^/])/(\w+)/?$ $1.php?customer=$2 [L]
Tested for
www.mysite.com/category_1/customer AND
www.mysite.com/category_1/customer/
www.mysite.com/category_2/customer AND
www.mysite.com/category_2/customer/
www.mysite.com/category_X/customer AND
www.mysite.com/category_X/customer/
Bye
I'm attempting to perform a simple 301 redirect via htaccess, the redirect works but adds "?folder=X" to the URL.
For instance:
Redirect 301 /pets http://www.mydomain.com/discount-pet-products
Returns:
http://www.mydomain.com/discount-pet-products?folder=pets
How do I remove this?
Here is my htaccess file
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
Redirect 301 /pets http://www.mydomain.com/discount-pet-products
RewriteRule ^([0-9a-zA-Z-]+)$ load.php?folder=$1 [L]
Try this:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^/pets$ http://www.mydomain.com/discount-pet-products? [R=301,L]
RewriteRule ^([0-9a-zA-Z-]+)$ load.php?folder=$1 [L]
Try this code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^pets/$ /discount-pet-products? [R=301,L]
RewriteRule ^([0-9a-zA-Z-]+)/?$ load.php?folder=$1 [L,QSA]
Make sure to test this in a new browser to avoid browser caching issues.
The answer was placing redirect at top of .htaccess file, before anything
RewriteRule ^pets$ http://www.mydomain.co.uk/discount-pet-products [R=301,L]