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>
Related
This is my URL after clicking the menu
http://mywebsite.com/page/english-lession/learn-about-influential-people
After that on the same page i have another menu for sorting. when i click on it, it is adding like &mode=advanced in url.
I have added mode variable in the last
http://mywebsite.com/page/english-lession/learn-about-influential-people&mode=advanced
This is my code:
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]
#RewriteRule ^([^/]*)/([^/]*)$ /page?lang=$1&id=$2 [L]
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /page\?lang=(.*)&id=(.*)\ HTTP
RewriteRule ^ /page/%2/%3\? [R,L]
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /page\?lang=(.*)&id=(.*)&mode=(.*)\ HTTP
RewriteRule ^ /page/%2/%3/%4\? [R,L]
</IfModule>
Please give me solution where i am wrong
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
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]
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]
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]