I'm using this htaccess file to rewrite links,
RewriteEngine on
RewriteRule ^([a-zA-Z]+)$ file.php?show=$1
But I'm having problem so, when i go to the page I wanted after rewrite like this: http://somesite.com/mypage
It goes to that page successfully, but when you type a slash in the end of the link (http://somesite.com/mypage/) it doesn't open and says 404 error..
Please fix the code so I can enter pages with slashes or without
RewriteEngine on
RewriteRule ^([a-zA-Z]+)(\/)?$ file.php?show=$1
Related
I have a url which is
www.domain.com/index.php?route=ticketsystem/generatetickets
I want people who type in the url www.domain.com/contact to be redirected to the page index.php?route=ticketsystem/generatetickets however have the url bar still show /contact is that possible via htaccess and if so how? I tried the below
RewriteEngine On
RewriteBase /
RewriteRule contact /index.php?route=ticketsystem/generatetickets [L,QSA]
For your shown attempts, please try following .htaccess rules file. Make sure your index.php and .htaccess files are present in same directory/folder. Also better to use & rather than using / for query string.
Make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^contact/?$ index.php?route=ticketsystem&generatetickets [QSA,NC,L]
I want to redirect from http://www.example.com/index.php?abz_xyz to http://www.example.com/abz_xyz with htaccess. I am using this code on my htaccess file Redirect /index.php?abz_xyz http://www.example.com/abz_xyz/ but this is not working kindly please help me
Something like this (my regex may be off)
The [L] means Last, so once the rewrite engine hits that line, it'll redirect immediately if it matches
RewriteEngine On
RewriteRule ^index\.php\?abz_xyz$ /abz_xyz/ [L]
I just learnt about url-rewrite for my website with .htacess. My actual url is:
localhost/index.php?view=some-page
So i write this RewriteRule like this:
RewriteRule ^/([^/]*)/?$ /index.php?view=$1 [NC,L]
When i typed localhost/homepage on my browser, It does not work, it displays error 404 object not found. What have i done wrong please show me.
Many thanks
This should work in your DocumentRoot/.htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/?$ index.php?view=$1 [QSA,L]
Leading slash is not matched in htaccess.
are you using apache?
This link from step 6 helped me
https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-on-ubuntu-14-04
When i was playing around with rewrites i had to enable it and tell apache where the pages were stored
I want to write a clean URL for my application. I searched and have written following, but it does not work and gives "Server not found error".
I have URL like this
http://localhost/projectFolder/user_folders/userName/testSite2/
and I want it to be -
http://testSite2.mySystemDomain.com/
I have tried as follows, but it fails.
RewriteEngine on
RewriteRule ^/user_folders/userName/testSite2/(.*) http://testSite2.mySystemDomain.com/$1
EDIT
There will be number of sites like testSite2. I need to write the URL for each such site.
Put this in .htaccess in folder projectFolder
RewriteEngine on
RewriteRule ^user_folders/(.*)/(.*) http://$1.mySystemDomain.com/$2 [R=301,L]
I'm a little stuck with with my .htaccess redirect.
It was working find while I was with PHP4 but the recent move to a new host with PHP5 have changed things for which I've no clue.
I'm working on a URL shortening service. Here, for a URL like http://example.com/e72b0f, it gives me http://example.com/forward.php?e72b0f
Earlier with my .htaccess file, the "forward.php?" was masked (hidden). How can I bring back this behavior. Here is the .htaccess for your reference.
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \/([0-9a-z]{6})$ [NC]
RewriteRule ^(.*) http://example.com/forward.php?%1 [L]
Btw, I also do not rule out the issue being in the PHP Script. The developer that did it for me is too busy to look at it.
If you rewrite to an http:// URL that the server doesn't think is in the site, mod_rewrite will do a redirect instead of just a rewrite. In order to see if this is happening, make a page that has nothing in it but
<?php echo $_SERVER['SERVER_NAME']; ?>
and see if says it's going to "nsfw.in".
Either way, you should be able to strip off the http:// nsfw.in from the beginning of the URL and just rewrite it to /forward.php?%1. You may need to add a PT flag in order for it to be interpreted as a URL and not a FS path.