This is the original URL
http://localhost/naranjeshaltd/index.php?url=home
and I want redirect it to
http://localhost/naranjeshaltd/home
I have tried this htaccess code but it is redirecting page to http://localhost/xampp
Options +FollowSymLinks
RewriteEngine on
RewriteBase /naranjeshaltd
RewriteRule ^(.*)$ /index.php?url=$1 [L]
But when I use this htaccess code everything working fine
Options +FollowSymLinks
RewriteEngine on
RewriteBase /naranjeshaltd
RewriteRule home$ index.php?url=home
but its a static method, how can I do this for all pages?
I can see 2 main issues here:
You should avoid redirecting to index.php for real file/dir/link.
Don't use / as the starting slash in target URL otherwise it will not be relative your RewriteBase
Change your code to this:
RewriteBase /naranjeshaltd/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]
Have you tried this?
Options +FollowSymLinks
RewriteEngine on
RewriteBase /naranjeshaltd
RewriteRule ^(.*)$ /naranjeshaltd/index.php?url=$1 [L]
Related
My default url is http://www.example.com/?page=20&id=2 and i want to show it as http://www.example.com/page/20/id/2/ with .htaccess
I use the following codes;
<IfModule mod_rewrite.c>
Options +FollowSymLinks +Indexes -MultiViews
RewriteEngine on
RewriteBase /
DirectoryIndex index.php
RewriteRule page/(.*)/id/(.*)/?$ ?page=$1&id=$2 [R=301,NE,NC,L]
RewriteRule page/(.*)/?$ ?page=$1 [R=301,NE,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /
</IfModule>
If i remove [R=301,NE,NC,L] at the end of the codes, /page/20/id/2/ is working if i go directly but when i write as ?page=20&id=2, url is not changed on browser.
If i use as the above it redirect from /page/20/id/2/ to ?page=20&id=2 which is the opposite of what i try to do.
i will appreciate if anyone can help me.
Thanks.
this should work
RewriteEngine On
RewriteCond %{HTTP_HOST} example.com$ [NC]
RewriteCond %{QUERY_STRING} page=(.*)&id=(.*)
RewriteRule ^$ /page/%1/id/%2? [L,R=301]
htaccess fiddle http://htaccess.mwl.be?share=afb950c7-106e-5b9c-a7ed-358aed027bc0
Hi I have the following redirection for a friendly URL site
Options +FollowSymLinks -Multiviews
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
rewritecond %{SCRIPT_FILENAME} !-d
rewritecond %{SCRIPT_FILENAME} !-f
rewriterule ^(.*)$ $1.php [L]
rewriterule ^noticia/([a-zA-Z0-9_-]+)$ noticia.php?title=$1 [L]
</IfModule>
If i go to www.mysite.com/noticias or any other URL like that everything goes ok
But if i try to go to www.mysite.com/noticia/this-is-a-parameter
When I access a link I do it like <a href="noticia/this-is-a-parameter">
I get Internal Server Error message and white screen
In localhost it was working perfectly, but can't find a solution in the server.
Any help would be appreciated
Check for presence of .php file before adding php extension and reorder your rules:
Options +FollowSymLinks -Multiviews
RewriteEngine on
RewriteBase /
RewriteRule ^noticia/([\w-]+)/?$ noticia.php?title=$1 [L,QSA,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
I am trying to do a url rewrite for php dynamic pages. The rewrite sends them to the page but I am getting a 404 error. In my php page i use $coinshow =$_REQUEST['coinshow'];
I want to to go from sitename.com/coinShowPage.php?coinshow=XyzShow to sitename.com/XyzShow or I would be happy with sitename.com/coinshows/XyzShow too.
Please note coinShowPage.php is the only page I need redirected.
Here is the .htaccess file
RewriteEngine On<br>
RewriteCond %{THE_REQUEST} ^[A-Za-z]{3,}\s/+coinShowPage\.php\?coinshow=([^\s]+) [NC]
RewriteRule ^ http://www.SiteName.com/%1? [R=301,L]
I already tried the following and it did not work
RewriteEngine On
Options +FollowSymlinks -MultiViews -Indexes
RewriteBase /
RewriteRule ^/([0-9]+)/?$ coinShowPage.php?coinshow=$1 [NC,L]
Any help would be greatly appreciated.
Try this:
Options +FollowSymlinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Za-z]{3,}\s/+coinShowPage\.php\?coinshow=([^\s]+) [NC]
RewriteRule ^ http://www.SiteName.com/%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ coinShowPage.php?coinshow=$1 [QSA,L]
i got a problem with rewriting my edit.php?id=1 to edit/id/1. Right now i have the following in my .htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^edit/id/([^/.]+)$ edit.php?id=$1 [NC]
This doesn't change the url. Can something see what i do wrong?
You need one additional rule to change the URL externally. This should be placed in root .htaccess:
RewriteEngine On
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/([^/]+)/edit\.php\?id=([^\s&]+) [NC]
RewriteRule ^ %1/edit/id/%2? [R=302,L,NE]
RewriteRule ^([^/]+)/edit/id/([^/.]+)$ $1/edit.php?id=$2 [NC,L,QSA]
Give this a try and see how it works for you.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/edit/id/([^/.]+)$ $1/edit.php?id=$2 [NC,L]
</IfModule>
OR you can do this if you only have a couple of directories the same. The will go in the root .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(profiles|customers|test)/edit/id/([^/.]+)$ $1/edit.php?id=$2 [NC,L]
</IfModule>
How would I modify my .htaccess to send http://rpgs.biz/rpg-test to just http://rpgs.biz/test
Here's my current .htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
rewriterule ^rpg-([^&]+)$ index.php?name=$1 [L]
I greatly appreciate any help, thanks!
If your current htaccess is taking rpg-(something) and passing the "something" into index.php, you'll need to change that as well. Maybe something like:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^rpg-([^/]+)$ /$1 [L,R=301]
# this is your old rule, modified
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ index.php?name=$1 [L]
This should work:
Redirect 301 /rpg-test http://rpgs.biz/test
But if you need to retain the files after /rpg-test, such as /rpg-test/cart.php or something, then you'd do:
RewriteRule ^rpg-test/?(.*) http://rpgs.biz/test/$1 [R=301,L]
If you want a simple redirect, it's easy:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^rpg-([^&]+)$ /$1 [L,R=301]