I have an URL that is https://www.myurl.com/subdir/language/login.php .
The "language" parameter is not an existing subfolder. The folder structure is:
root/subdir/.htaccess
As you can see the .htaccess file is located in https://www.myurl.com/subdir/.htaccess
I would like to do a .htaccess Rewrite Rule in order to change the called uri:
https://www.myurl.com/subdir/en/login (without .php)
to:
https://www.myurl.com/subdir/login.php?lng=en
My current apporach is:
# MultiViews must be disabled for the rewrite to work
Options -MultiViews
# Turn on the rewriting engine
RewriteEngine On
RewriteBase /subdir/
RewriteRule (en|de)(/login)$ login.php?lng=$1 [L]
But when I call the URI https://www.myurl.com/subdir/en/login I get an http error code 404.
Yes thats it! One more question, what if the scenario is all the same, but I would like to get the (en/de) in front of /subdir/ ? So the url would be myurl.com/en/subdir/login:
In this case rule must be placed in site root .htaccess instead of subdir/.htaccess with this rule:
Options -MultiViews
RewriteEngine On
RewriteRule ^(en|de)/(subdir/login)/?$ $2.php?lng=$1 [L,QSA,NC]
Related
I have a single point of entry on my website
mysite.com/admin/index.php?View=List&Model=User
All access to the DB/application is through this index.php file.
I would like to clean my URL from what is shown above to.
mysite.com/admin/List/User
The idea is to remove the key 'Model and 'View'.
I have found this link that looks very similar.
PHP/Apache: Rewrite rules with .htaccess
in htaccess file insert this code :
RewriteEngine On
RewriteRule ^admin/([^/]*)/([^/]*)$ /admin/index.php?View=$1&Model=$2 [L]
The rewritten URL:
http://mysite.com/admin/List/User
this site very useful for generate rewrite URL
http://www.generateit.net/mod-rewrite/
Create a file named .htaccess in your web root if you haven't already got one with the following:
# Turn the rewrite engine on (skip this if already done)
RewriteEngine On
# Redirect admin/List/User/ to admin/index.php?View=List&Model=User
RewriteRule ^admin/([^/.]+)/([^/.]+)/?$ admin/index.php?View=$1&Model=$2 [L]
This might work:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^admin/([^/]+)/([^/]+) /index.php?View=$1&Model=$2 [NC]
Add to .htaccess in the root folder of your website.
I'm changing my website links to a SEO friendly urls, I did every thing in php file and changed the urls as following:
http://mywebsiet.com/news-details.php?id=2012/6/21/newstitle.html
how can I redirect to:
http://mywebsiet.com/2012/6/21/newstitle.html
I tried this Generating tool from www.generateit.net/mod-rewrite/
and created the .htaccess with the code provided:
RewriteEngine On
RewriteRule ^([^_]*)$ /news-details.php?id=$1 [L]
and even so, nothing get changed.... any ideas?
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 /
RewriteRule ^(.+?\.html)$ /news-details.php?id=$1 [L,QSA,NC]
I have a url of the form:
www.example.com/r/abc/1234
that I want to rewrite to:
www.example.com/r.php?deb=abc&id=1234
And another url:
www.example.com/r/12bcd-qsqs-343-wdwd/1234
which should be rewritten to:
www.example.com/r.php?abc_id=12bcd-qsqs-343-wdwd&id=1234
Both of these rule should be handled by .htaccess. Any suggestions?
Both the URIs that you want to redirect look similar except that 2nd one has hyphens - in first query parameter.
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 /
RewriteRule ^r/([^-]+)/(.+)/?$ r.php?deb=$1&id=$2 [L,QSA]
RewriteRule ^r/([a-z0-9-]+)/(.+)/?$ r.php?abc_id=$1&id=$2 [L,QSA,NC]
Try something like :
RewriteRule (.*)/(.*)/(.*)$ path_to_php_files/$1.php?deb=$2&id=$3 [QSA,L,NC]
Unfortunately with this rule, you would have the first $_GET parameter always deb and I hope you have the DirectoryIndex set up corectly. I do not think that for
www.example.com/r/abc/1234
www.example.com/r/12bcd-qsqs-343-wdwd/1234
you can delivrer the abc and 12bcd-qsqs-343-wdwd to 2 different $_GET parameters if you have dynamic links.
I have a single point of entry on my website
mysite.com/admin/index.php?View=List&Model=User
All access to the DB/application is through this index.php file.
I would like to clean my URL from what is shown above to.
mysite.com/admin/List/User
The idea is to remove the key 'Model and 'View'.
I have found this link that looks very similar.
PHP/Apache: Rewrite rules with .htaccess
in htaccess file insert this code :
RewriteEngine On
RewriteRule ^admin/([^/]*)/([^/]*)$ /admin/index.php?View=$1&Model=$2 [L]
The rewritten URL:
http://mysite.com/admin/List/User
this site very useful for generate rewrite URL
http://www.generateit.net/mod-rewrite/
Create a file named .htaccess in your web root if you haven't already got one with the following:
# Turn the rewrite engine on (skip this if already done)
RewriteEngine On
# Redirect admin/List/User/ to admin/index.php?View=List&Model=User
RewriteRule ^admin/([^/.]+)/([^/.]+)/?$ admin/index.php?View=$1&Model=$2 [L]
This might work:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^admin/([^/]+)/([^/]+) /index.php?View=$1&Model=$2 [NC]
Add to .htaccess in the root folder of your website.
For URL Rewriting, i have got the output for static URL
But , for dynamic URL , i am getting partial output only.
I have placed the .htaccess file in the root directory only.
Here is the code:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^booking/price/([0-9]+)/?$ booking.php?price=$1
What will be the solution ?
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^booking/([0-9]+)/?$ booking.php?price=$1
RewriteRule ^booking/([0-9]+)/([0-9]+)/?$ booking.php?price=$1&pass=$2
You really want to customise your code for these though so as to be able to use general rules, rather than converting specific paths to use $_GET.
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^booking/([0-9]+)/?$ booking.php?price=$1
RewriteRule ^booking/([0-9]+)/([0-9]+)/?$ booking.php?price=$1&pass=$2
For images and Css you need to define your base folder in htaccess file as
RewriteBase /~your folder/