url rewrite on godaddy dynamic php pages - php

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]

Related

RewriteRule is working opposite or not working?

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

Rename domain cause empty page

I'm trying to rename my domaine via htaccess fom http://old.com/page to http://new.com/page , in the first page http://new.com/ working fine, but when I want to go to other page I have 2 problems:
the the url not changed they have always the some text , like :
http://new.com/
the rewriting of page does not working until I
add .php like this : http://new.com/page.php
this is my htaccess code :
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^old\.com [NC]
RewriteRule ^/(.*) http://new.com/$1 [R=301,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)$ http://new.com/$1 [R=301,NC]
RewriteRule ^page$ page.php [QSA,NC]
I'm really have no idea about this :(((
I may be wrong, but I think you don't need to add / in your RewriteRule ^/(.*) http://new.com/$1 [R=301,NC] line.
Try this and let me know (I havent tested it) :
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^old\.com [NC]
RewriteRule ^(.*) http://new.com/$1 [R=301,NC]
# -----------^-------- the change is here
This should redirect any page from old.com to the same page on new.com.
You can use this :
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
#redirect "olddomain.com/" to "newdomain.com/"
RewriteCond %{HTTP_HOST} ^old\.com [NC]
RewriteRule ^$ http://new.com/ [R=301,L]
#rewrite "olddomain.com/page" to "olddomain.com/.php"
RewriteRule ^page$ page.php [L,NC]

Htaccess URL redirect not working in godaddy

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]

Htaccess rewrite with id

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>

.htaccess file is not working on server

I have a URL like this
www.subdomain.mydomain.com/mydir/admin/index.php?page=dashboard
I want to have a user friendly url like this
www.subdomain.mydomain.com/mydir/admin/dashboard
How do I achieve this? I am trying with the below mentioned code. What am I doing wrong here?
Options -MultiViews
# URL rewriting module activation
RewriteEngine on
RewriteCond %{REQUEST_METHOD} !^(TRACE|TRACK|GET|POST|HEAD)$
RewriteRule .* - [F]
RewriteBase /
Options +FollowSymLinks
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1 [L]
For a similar context please refer this question.
Try this .htaccess:
Options +FollowSymLinks -MultiViews
RewriteEngine on
# use appropriate rewrite base
RewriteBase /mydir/admin/
RewriteCond %{REQUEST_METHOD} !^(TRACE|TRACK|GET|POST|HEAD)$
RewriteRule ^ - [F]
RewriteCond %{THE_REQUEST} /index\.php\?page=([\w-]+) [NC]
RewriteRule ^ %1? [L,R]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ index.php?page=$1 [L,QSA]

Categories