I want to rewrite the url in my project.
For example:
http://www.example.com/dashboard/test/ to http://dashboard.example.com/index.php
Also I want to do it for:
http://www.example.com/dashboard/test2/ to http://dashboard.example.com/index.php
Can anyone tell me the idea to rewrite the url?
First you create a .htaccess file in your root.
Than, just put the redirect commands in it.
How to compose a .htaccess and how to create rewrite rules is explained here: http://net.tutsplus.com/tutorials/other/the-ultimate-guide-to-htaccess-files/
You will need something like:
RewriteRule ^(.*)$ http://dashboard.example.com/$1 [L,QSA]
try this
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^test.*$ http://dashboard.example.com/index.php [R=301,L]
Related
Following is my rewrite rule code written in the .htaccess file placed in the
beta1
folder.
Options +FollowSymlinks
RewriteEngine on
RewriteBase /beta1/
RewriteRule /(.*) read.php?post=$1 [R,NC]
Currently the URL is:
http://localhost/beta1/read.php?post=Happy+Mother+Day.
And i want the link to appear like:
http://localhost/beta1/Happy-Mother-Day.
Do I also need to change the way "read.php" extracts data from the database? If yes, then how?
Do i also need to make any changes in the "read.php" file?
The rewrite code above is not working.
hey please try this rule
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^([A-Za-z0-9-_]+)?$ read.php?post=$1 [NC,L]
And read.php file
echo str_replace('-',' ', $_GET['post']);
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 am using WAMP and my url is localhost/hotel/hotels.php?id=21
Using rewrite rule as follow,
Options +FollowSymLinks
RewriteEngine on
RewriteRule hotels/id/(.*)/ hotels.php?id=$1
RewriteRule hotels/id/(.*) hotels.php?id=$1
But nothing happens..
My mod_rewrite is on and also changes done in httpd.conf file.
Please give me a suggestion to handle the issue?
You must use flags for your RewriteRule. You can change it as follow
RewriteEngine on
RewriteRule ^hotels/id/([\d]+)/?$ hotels.php?id=$1 [NC,L]
You can call your pages from
localhost/hotel/hotels/id/12
If your .htaccess file is located in localhost/hotel .
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 am new to htaccess and want to do following thing,
I want to rewrite url like,
http://example.com/test/test.php to http://example.com/test.html
and my htaccess file present in test folder. Can anyone help to find out this problem.
Thank You
That should do it:
RewriteEngine on
RewriteRule ^(.*).html$ test/$1.php [QSA]