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]
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
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'm having a problem with my mod rewrite rule that I wrote for my website, nothing seems to change as my pages URL are loading the same as before, if anyone could have a look at it and let me know if there is any problems it would be very much appreciated, thanks!
REWRITE RULE
RewriteEngine On
RewriteRule ^([^/]*)/$ /index.php?art_id=$1 [L]
URL
http://www.test.com/index.php?art_slug=test
DESIRED RESULT
http://www.test.com/test
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# to externally redirect from /index.php?art_slug=test to /art_slug/test
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+/(?:index\.php|)\?([^=]+)=([^\s]+) [NC]
RewriteRule ^ /%1/%2? [R=302,L]
# to internally forward from /art_slug/test to /index.php?art_slug=test
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]+)/(.+)$ /index.php?$1=$2 [L,QSA]
Once you verify it is working fine, replace R=302 to R=301. Avoid using R=301 (Permanent Redirect) while testing your mod_rewrite rules.
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php?art_id=$1 [L]
Should work. :)
RewriteEngine On
RewriteRule (.*)/$ search.php?keyword=$1
Should work. :)
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]
I'm using the Silex "micro-framework" for routing purposes of my application.
I'm currently stuck on how to rewrite the url with .htaccess.
Standard Silex url: localhost/myapp/web/index.php/hello/name
I want it to look like: localhost/myapp/hello/name
With the following .htaccess code, I'm able to omit the /index.php/ part. But I still have to use the /web/ part.
RewriteEngine On
RewriteCond %{THE_REQUEST} /myapp/web/index.php/
RewriteRule ^/myapp/web/index.php/(.*) /myapp/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !/myapp/web/index.php/
RewriteRule ^(.*)$ /myapp/web/index.php/$1 [L]
Any suggestions?
Thanks!
I've faced the same problem right now and the solution was to change .htaccess content to:
FallbackResource /index.php
So in your case it would be
FallbackResource /web/index.php
This worked for me and I hope someone will find it useful.
From: http://silex.sensiolabs.org/doc/web_servers.html
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
The right would be to set up your DocumentRoot to /path/to/your/app/web.
Something like this should do the trick:
RewriteEngine On
RewriteBase /
RewriteRule ^myapp/web/index.php/ /myapp/ [R=301,L]
RewriteRule ^myapp/ /myapp/web/index.php/ [L]
I had a similar problem, solved with the following
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)? index.php/$1 [QSA,L]
RewriteRule ^/?$ /web/ [R=301]
</IfModule>