.htaccess file is not working on server - php

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]

Related

i want to change my URL Through htacess

i want to change my url through .htaccess here is all code i am trying.
i write 2 codes for same page, in second page i am adding mode varible but it is showing me like this :
free/english-lession/learn-about-influential-people&mode=advanced
Options -Indexes
<IfModule mod_rewrite.c>
Options +MultiViews
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /page\?type=(.*)&lang=(.*)&id=(.*)\ HTTP
RewriteRule ^ /page/%2/%3/%4\? [R,L]
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /page\?type=(.*)&lang=(.*)&id=(.*)&mode=(.*)\ HTTP
RewriteRule ^ /page/%2/%3/%4/%5\? [R,L]
</IfModule>

URL rewriting with Wordpress Rewrite or .htaccess

I'm trying to append to wordpress an additional parameter into my URL.
For example, I have the URL: http://example.com
I want to change that to URL: http://example.com/this-example/
I'm thinking I can do this is in htaccess along the lines of a rewrite condition, but i'm unsure how to go about this. This is what I was thinking here.
Htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteEngine on
RewriteRule ^/this-example/(.*)/ /index.php?$1 [L]
</IfModule>
Options -Indexes
You can try this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{THE_REQUEST} !^/this-example [NC]
# use your own host here, for me is 192.68.10.10
RewriteCond %{HTTP_HOST} 192\.168\.10\.10$ [NC]
RewriteRule !^this-example/ /this-example%{REQUEST_URI} [L,R,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^this-example/(.*)$ $1 [L,QSA]
</IfModule>
Options -Indexes

how to write conditional .htaccess file

My Site's every pages has Different URL with Seo variable, on page click URL becomes
index.php?seo=home
rates.php?seo=rates
reservation.php?seo=reservation
now i want to convert the URL to this
agnow.us/rates
agnow.us/information
agnow.us/reservation
Here is my .htaccess file.
Options +SymLinksIfOwnerMatch -Multiviews
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+rates\.php\?seo=([^\s&]+) [NC]
RewriteRule ^ /%1? [L,R=301]
RewriteRule ^/(.*)$ rates.php?seo=$1 [L,NC,QSA]
You can use this code in your root .htaccess:
Options +SymLinksIfOwnerMatch -Multiviews
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+rates\.php\?seo=([^\s&]+) [NC]
RewriteRule ^ /%1? [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ rates.php?seo=$1 [L,NC,QSA]

url rewrite on godaddy dynamic php pages

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]

.htaccess How to match only the first appearance of index.php in the URL?

I have the following question. Let's say I have link like
http://localhost/test/index.php/admin
I have the following htaccess:
Options -MultiViews
Options +FollowSymLinks
Options -Indexes
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) $1$2 [R=301,NE,L]
What it does is simply remove index.php from the URL. However, when I enter url like this:
http://localhost/test/abc/blabla/index.php
It goes on an infinite loop. What I want is to do nothing when another index.php is met in the URL. How can I achieve this? Thanks!
Replace your code with this:
Options +FollowSymLinks -MultiViews -Indexes
RewriteEngine On
RewriteBase /test/
RewriteCond %{QUERY_STRING} !(^|&)r(&|$)
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php(?:/(.*))?$ $1$2?r [R=302,NE,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!index\.php/).+)$ index.php/$1 [L,NC]

Categories