I want create a user's page, like twitter, who have more options, like: site.com/u/User but i want create multiples, like: site.com/u/User, site.com/u/User/photos, i try it:
RewriteRule ^u/(.+)$ perfil/?user=$1 [L,QSA]
RewriteRule ^u/(.+)/t$ perfil/?user=$1&t=1 [L,QSA]
But it doesn't works, anyone can help me?
Forgot, i founded it, lol, i found here http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html
Just change (.*) to ([a-zA-Z0-9_-]+)
Related
I've been searching and cannot find an answer that suits my needs. It is a rather simple question I assume.
The point is that I need to rewrite my files to a name of my liking. For example I have, 'www.mydomain.com/account_index.php' which I want to rewrite to www.mydomain.com/account
Thus far I had this, but that doesn't seem to work with multiple lines.
Rewriteengine on
rewriterule ^support account_ticket.php [L]
rewriterule ^account account_index.php [L]
So in short, I want my website to redirect /account to account_index.php and the other way around.
Thanks in advance!
I found the answer for those that are wondering.
I had to put a RewriteCond before every RewriteRule.
So if I wanted to go to www.mydomain.com/account. I'd have this:
RewriteCond %{REQUEST_URI} ^/account$ [NC]
RewriteRule ^account account_index.php [NC,L]
This means that /account is now linked to account_index.php.
Have a nice day!
For some reasons a google addbot generates links like:
https://batteryservice.bg/продукт/фенер-nitecore-mt40gt/batteryservice.bg
I would like to remove this last part /batteryservice.bg and have something like:
https://batteryservice.bg/продукт/фенер-nitecore-mt40gt/
I tried this solution like : RewriteRule ^(.+)/batteryservice.bg /$1 [R=301,L,NC] But this didn't worked for me.
This one worked, strangely enough RewriteRule ^(.+)/batteryservice.bg https://batteryservice.bg/$1 [R=301,L,NC]
I know this problem is over asked, but couldnt find anything fitting with my problem.
I'm currently creating a website, and my url are like :
www.foo.com/
or www.foo.com/index.php.
They can take 1, 2 ,or three different parameters like
www.foo.com/index.php?page=Home&lang=en&article=1
What i'd like is an url like
www.foo.com/Home/
or www.foo.com/en/Home
or www.foo.com/Article/1
or www.foo.com/en/Article/1
The page parameter is required, other two are not..
I cant have anything working for me... Any help would be greately appreciated
Thanks a lot !
Better to have separate clean rules. Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule ^([^/]+)/?$ /index.php?page=$1 [L,QSA]
RewriteRule ^([a-z]{2})/([^/]+)/?$ /index.php?page=$2&lang=$1 [L,QSA]
RewriteRule ^([a-z]{2})/([^/]+)/([0-9]+)/?$ /index.php?page=$2&lang=$1&article=$3 [L,QSA]
RewriteRule ^([^/]+)/([0-9]+)/?$ /index.php?page=$1&article=$2 [L,QSA]
Try something like this
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)/([a-z0-9_-]+)\.html$ index.php?param1=$1¶m2=$2¶m3=$3
I am new to .htaccess and I seem to be having some problems getting it to clean up the url for me.
I have
site.com?p=article&id=3&read=article title
I am able to get the first variable to work ok like site.com/articles. but when I try to go further the server is saying it cant find it. I have tried several methods none of which seem to be working.
RewriteRule ^([a-zA-Z0-9]+)$ index.php?p=$1
RewriteRule ^([a-zA-Z0-9]+)/$ index.php?p=$1
this above is working
I have tried
RewriteRule ^([a-zA-Z0-9-z\-]+)(/([a-zA-Z0-9-z\-]+))?/?$ index.php?p=$1&i=$2
and
RewriteRule ^([a-zA-Z0-9-z\-]+)/([a-zA-Z0-9-z\-]+)/([a-zA-Z0-9-z\-]+)/?$ index.php?p=$1&i=$2&read=$3
the last 2 are not working. help please. Thanks
Let's try something like this?
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?p=$1&id=$2&read=$3 [L]
%{QUERY_STRING} is what you are looking for.
this is what I use for a similar situation:
RewriteRule ^/(.*) /index.php?r=/$1&%{QUERY_STRING} [L]
Ok I want to simulate the YouTube URL and redirect it to my real URL. Reason being is I used a random string to make video ID's so they aren't guessable by sequence.
I have the links as so
http://www.mysite.com/watch?v=Dxdotx3iT1
and want to redirect to
http://www.mysite.com/index.php?page=videos§ion=view&v=Dxdotx3iT1
Can't seem to figure out the mod rewrite. Also using a ? I believe tells it to do something.
Any help would be appreciated.
You need to adjust your RewriteRule to include the query string using the [QSA] (query string attached) flag:
RewriteRule ^watch$ index.php?page=video§ion=view [QSA]
RewriteCond %{QUERY_STRING} ^v=(.+)
RewriteRule ^watch /index\.php?page=videos§ion=view&v=%1 [QSA,R=301,L]
None of these answers worked for me, so in the end I found through trial and error the following worked for me;
The RewriteRule to get my URL to look like this https://www.example.com/video/watch?v=UnIq3Id follows;
RewriteRule ^video\/watch\?*$ index.php?page=video [L,QSA]
I found that the following rule I had previously set up to make my URL look like this https://www.example.com/video/UnIq3Id interfered with my redirecting;
RewriteRule ^/?([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ index.php?page=$1&v=$2
Simply commenting it out fixed the issue, as follows;
#RewriteRule ^/?([A-Za-z0-9_-]+)/([A-Za-z0-9_-]+)$ index.php?page=$1&v=$2
The RewriteRule to get my URL to look like this https://www.example.com/watch?v=UnIq3Id is as follows;
RewriteRule ^watch\?*$ index.php?page=video [L,QSA]
I found that the following rule I had previously set up to make my URL look like this https://www.example.com/video/ interfered with my redirecting;
RewriteRule ^([A-Za-z0-9_-]+)/?$ index.php?page=$1 [NC]
Simply commenting it out fixed the issue, as follows;
#RewriteRule ^([A-Za-z0-9_-]+)/?$ index.php?page=$1 [NC]
Hope it helped someone and saved you the headache I had, people are not so forthcoming on this issue at times How do you write an htaccess RewriteRule to make my urls work like youtube?.