So I have the url: myurl.com/projects/url/visit.php?link=fbehe and I want to rewrite it as so:
myurl.com/u/fbehe
But it isn't working. I am using this so far:
RewriteEngine On
RewriteRule ^/u/([^/]*)$ visit.php?link=$1 [L]
I would also like to note that I placed my htaccess file in the directory with my visit.php file. so myurl.com/projects/url/.htaccess
How could I achieve this?
You may try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/u/([^/]+)/?$ [NC]
RewriteRule .* projects/url/visit.php?link=%1 [L]
Maps silently
http://myurl.com/u/anyvalue with or without trailing slash
To
http://myurl.com/projects/url/visit.php?link=anyvalue
Try using NC as well. Also, not sure if the absolute path is working. Try a relative if the .htaccess is in the root of your website.
RewriteRule ^/u/([^/]*)$ visit.php?link=$1 [L,NC]
do you use any framework of this? maybe u can you there functionality like routes. can rewrite your url..
Like Codeigniter,Cake
They have routes to change the url like that.
Related
I have this problem, I'm using my url like this:
If somebody is coming to the website from a referral the have something like https://myweb.site/UERHF723R so my htaccess have this:
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?ref=$1 [L,QSA]
but how I can send somebody to https://myweb.site/foldername without send them to index.php as a variable.
I think I can use something like this:
RewriteCond %{REQUEST_URI} foldername
RewriteRule .* /foldername/index.php
But I don't want to to this for every new folder, any suggestions?
You can use:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?ref=$1 [L,QSA]
In this way, you only rewrite urls that are not directories (-d) or files (-f)
The second line is therefore not mandatory in your case.
I'm sure this has been asked in other forms, but I can't for the likes of me get this thing working after googling/trying for hours.
I have a bunch of URLs like this:
www.yoursite.com/pic_box.php?pic=$
What I want is that all URLs will only be avaiable with clean URLs.
www.yoursite.com/your-title-here
Can any htaccess master help me with this?
In your .htaccess:
RewriteEngine on
RewriteRule ^picbox/(.*)$ /pic_box.php?pic=$1 [NC,L]
Will give you the ability to rename your url like that:
www.yoursite.com/picbox/your-pic-id
Try adding these rules to the htaccess file in your document root:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /pic_box.php?pic=$1 [L]
I am working on one website.
On this website, porfile URL currently is like this:
http://eprofile.co/eprofile.php?user=degroundshaker
I want to rewrite this URL as:
http://eprofile.co/degroundshaker
This, is addon domain so its files are under a folder called "eprofile.co" in my cPanel and there is one .htaccess file.
So, i need solution and please let me know what rule i need to add and what should be the complete format in .htaccess
I m newbie in .htaccess.
Try this:
RewriteEngine On
RewriteRule ^([^/]*)$ /eprofile.php?user=$1 [L]
Try putting this in the htaccess file in your document root:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ /eprofile.php?user=$1 [L]
Then you need to change all of your profile links from looking like this:
http://eprofile.co/eprofile.php?user=degroundshaker
to looking like this:
http://eprofile.co/degroundshaker
EDIT:
Alternatively, you could do:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/eprofile.php
RewriteRule ^([^/]*)$ /eprofile.php?user=$1 [L]
currently i have a /en/ folder that is empty except for a .htaccess with the following
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)$ ../index.php?language=en$1 [NC]
i use it to eliminate the need for
index.php?language=en
in all my URLs. I would like to modify the htaccess in a way that i no longer need the /en/ folder with nothing but the htaccess inside. ideally i would like an htaccess in my root folder that reads the url and if it is www.example.com/en/ to rewrite to www.example.com/index.php?language=en
This should work for you:
RewriteRule ^en/(.*)$ index.php?language=en$1 [NC]
Put the following code in .htaccess file in your root folder.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^en/(.*)$ index.php?language=en$1 [L]
Here $1 will append rest of the url as well. The condition will also help if you request your files using direct url.
I have created a simple mod rewrite for my site:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(cgi-bin|css|images|js|gfx)/?.*$ [NC]
RewriteRule ^filter/model/([^/]*)/mins/([^/]*)/texts/([^/]*)/freegifts/([^/]*)/network/([^/]*)/merchant/([^/]*)$ /fiverrr.php?model=$1&mins=$2&texts=$3&freegifts=$4&network=$5&merchant=$6 [L]
but it doesn't seem to be working (as in all the images/js etc don't show up)
e.g. http://mydomain.com/filter/model/Sony+Ericsson+Xperia+Arc+S+White/mins/+3000/texts/+-1/freegifts/FREE+Nintendo+3DS+Black/network/Orange/merchant/
original url: http://mydomain.com/fiverrr.php?model=Sony+Ericsson+Xperia+Arc+S+White&mins=+3000&texts=+-1&freegifts=FREE+Nintendo+3DS+Black&network=Orange&merchant=Contract
Where am I going wrong, and is this the best method?
Thanks so much
Try to put there another condition - htaccess will rewrite it only if requested file does not exist:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^filter/model/([^/]*)/mins/([^/]*)/texts/([^/]*)/freegifts/([^/]*)/network/([^/]*)/merchant/([^/]*)$ /fiverrr.php?model=$1&mins=$2&texts=$3&freegifts=$4&network=$5&merchant=$6 [L]
Also I recomend you to check full paths. Check if you have images in HTML code like: http://mydomain.com/images/img.jpg - relative paths like ./../images/img.jpg will not work!