I have a .htaccess which reads as follows
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^([a-z0-9\-]+) /index.php?page_name=$1 [L]
I want the link
http://www.solublesilicates.com/our-services when clicked should read as http://www.solublesilicates.com/?page_name=our-services.
Please do help.
RewriteRule ^([a-z0-9\-]+)$ /index.php?page_name=$1 [L, QSA]
Just change it to the above. Should work perfectly.
You have error in your syntax. Your regex should end with $ sign
RewriteRule ^([a-z0-9\-]+)$ /index.php?page_name=$1 [L]
Change the Rewrite Rule to
RewriteRule ^([A-Za-z0-9\-]+) index.php?page_name=$1 [L,QSA]
Related
i get the $_GET['id'] from url to show a page, to htaccess i have the follow code to show like this shop/123 and not shop.php?id=123
RewriteEngine on
RewriteRule shop/(.*)/ shop.php?id=$1
RewriteRule shop/(.*) shop.php?id=$1
My problem is .. If i add to url shop/123/test/test/test this still working again and i have problems with the share links etc.
How i can fix it to takes only one parametes else to go to 404?
Sorry for my English
You can use this :
RewriteEngine on
RewriteRule ^shop/([^/]+)$ /shop.php?id=$1 [L]
This will rewrite /shop/foobar to /shop.php?id=foobar, but will not rewrite /shop/foobar/ with a traling slash or extra path-info .
If id is only numerical, you can change the rewrite rule to this:
RewriteEngine on
RewriteRule shop/(\d+)/ shop.php?id=$1
RewriteRule shop/(\d+) shop.php?id=$1
If you also have alphabets in id:
RewriteEngine on
RewriteRule shop/([a-zA-Z\d]+)/ shop.php?id=$1
RewriteRule shop/([a-zA-Z\d]+) shop.php?id=$1
Try this:
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>
RewriteRule ^shop/([0-9]+)/(.*) shop.php?id=$1 [L]
RewriteRule ^shop/([0-9]+)/(.*)/ shop.php?id=$1 [L]
Hope this will work. Thanks.
My .htaccess file as below,
DirectoryIndex routing.php
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+Milan_Practice/Milan_Mvc/routing\.php[\s?] [NC]
RewriteRule ^ Milan_Practice/Milan_Mvc/ [L,R=302]
RewriteRule ^Milan_Mvc/?$ Milan_Mvc/routing.php [L,NC]
By Appling above code I got url like below,
http://localhost/Milan_Practice/Milan_Mvc/?name=about
in above,there after "?",data is not in valid format as I want like this,
http://localhost/Milan_Practice/Milan_Mvc/about/
So please give your suggestion with proper ReWriting Rule for above code
ThankYou in Advance !!!
RewriteRule ^([a-z]{2,2})/([a-zA-Z0-9_-]+)$ index.php?name=$1 [QSA]
See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
I am trying to redirect www.mysite.com/movie/name to www.mysite.com/movie/?url=name
for this I have added htaccess in movie/ folder, the code I have added is below:
RewriteEngine On
RewriteBase /movie/
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+).html$ index.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?id=$1
I am unable to redirect it, could anybody suggest me the right way to accomplish this?
Just a small change and it should work..
Try below code and let me know whether it worked for you or not..
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+).html$ index.php?id=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ index.php?id=$1
Hope it helps...
First off, you only need to write command RewriteEngine On once.
Besides, replace last rule for
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?id=$1
The fault was in the last backslash.
I need a rewrite rule to rewrite the following:
www.abc.com/page/xyz to www.abc.com/xyz
remove **"page"** from url
I think it's more like this:
RewriteBase /
RewriteRule ^(.*)$ page/$1 [L]
If I understand what you're trying to do.
Like so:
RewriteBase /
RewriteRule ^page(/.*)?$ $1 [L]
If you only want to redirect page/xyz then you can use:
RewriteEngine on
RewriteRule ^/page/xyz$ /xyz [L]
If you want to redirect anything within the page directory, then use:
RewriteEngine on
RewriteRule ^/page(/.*$)$ $1 [L]
I'm try to rewrite my url
http://www.domain.com/live/randomword
it should go rewrite to
http://www.domain.com/live/?cat=randomword
here are my tests:
RewriteRule ^live/(.*)$ /live/?cat=$1
RewriteRule ^live/(.*)$ live/?cat=$1
and all i have in the htaccess file is:
RewriteEngine on
You should try to add a RewriteBase / to your .htaccess and to suffix your rule with a [L] to say it's last rewrite rule ending with something like that:
RewriteEngine on
RewriteBase /
RewriteRule ^live/(.*)$ live/index.php?cat=$1 [L]
If this still doesn't work be sure to check that mod_rewrite is enabled
also you can do a [R,L] instead of [L] to see the redirection in the url and so have more info on what's going own.
hope this help
Have this code in your .htaccess file:
Options -MultiViews +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^live/(.*)$ /live/?cat=$1 [L,NC]
in rewrite rule the file name or extension in missing?
write rule like,
RewriteRule ^live/([a-zA-Z0-9_-]+)$ /viewcategory.php?cat=$1