why this doesnt work? rewriting URL - .htaccess

I want to rewrite this URL: /PIT/employee/student-profile/2
This works:
RewriteRule ^employee/([0-9]+) employee/student-profile.php?id=$1
This doesn't work:
RewriteRule ^employee/student-profile/([0-9]+) employee/student-profile.php?id=$1
I want it to be like this: /PIT/employee/student-profile/2

Related

I need a fancy htaccess rewrite to query string

I need a rewrite for htaccess that will take this sample url and rewrite it to the homepage and get rid of the query string.
Example:
Rewrite this:
http://www.domain.com/e-newsletters/forward/49.html?key=BkPOBo4l&tmpl=component
to this:
http://www.domain.com/
Here are the "variables" in the url:
49.html there could be any number.html
?key=BkPOBo4l - the string "BkPOBo4l" will change
&tmpl=component will not change
Any help would be greatly appreciated.
To redirect
http://www.domain.com/e-newsletters/forward/49.html?key=BkPOBo4l&tmpl=component
to http://www.domain.com/
You can use the following :
RewriteEngine on
RewriteCond %{THE_REQUEST} /e-newsletters/forward/[0-9]+\.html\?key=.+&tmpl=component [NC]
RewriteRule ^ http://www.domain.com/? [L,R]

Rewrite .htaccess without query string

My URL Syntax Now is Like
http://20percents.com/au/restaurant/?shop=Fantasia%20MacArthur%20Central
And, how can I rewrite it to like
http://20percents.com/au/Fantasia-MacArthur-Central
Remove restaurant from url, remove ?shop from url, and change the %20 to -
I tried like
RewriteEngine on
RewriteRule ^restaurant/([^/\.]+)/?$ restaurant?shop=$1 [L]
This didn't work
I also tried like, and this too didn't work.
RewriteCond %{QUERY_STRING} val
RewriteRule ^/restaurant/?shop
Thanks

Using .Htaccess url redirection

I want to rewrite my url but i cant do proper way.
mysitename.net/index.php?title=Category:Public_Companies&pagefrom=8
To :
mysitename.net/Category:Public_Companies/8
How can i do that.
If you have other pages than Category, I recommend to use this:
RewriteRule ^Category:(.+)/(.+)$ /index.php?title=Category:$1&pagefrom=$2 [L]
Otherwise, use this:
RewriteRule ^(.+)/(.+)$ /index.php?title=$1&pagefrom=$2 [L]

.htaccess rewrite with GET param

Im trying to transfrom link like this:
http://localhost/photohosting/user/view.php?img=60
Into something like that in users browser:
http://localhost/photohosting/60
Here my code for .htacces
RewriteEngine on
RewriteRule ^view.php(.*)$ /photohosting/user/view.php?img=$1 [L,QSA]
I'm not familiar with .htaccess so I can't found the mistake. Why this code doesn't work?
UPDATE: I've updated my .htaccess to:
RewriteRule ^([a-zA-Z0-9_-]+)$ user/view.php?img=$1 and now link like http://localhost/photohosting/60 works, but it misses param.
Try with the following rule:
RewriteRule photohosting/([0-9]+)$ /photohosting/user/view.php?img=$1 [L,QSA]

Multiple variables in rewrite mod

I am new in rewrite mod and i want to make something like when user go to: http: mysite.qqq/news/it/some_news1 real URL will be: http:// mysite.qqq/index.php?s=news&d=it&i=some_news1. But i don't know how to make this. I need help.
Now i have .htaccess:
RewriteEngine On
RewriteRule ^([a-z_]*)/?$ index.php?s=$1 [QSA]
And i am thinking to add something like:
RewriteRule ^([a-z_]*)/([a-z_]*)/([a-z0-9_]*)/?$ index.php?s=$1&d=$2&i=$3 [QSA]
But it doesn't working.
RewriteRule ^/(.+?)/(.+?)/(.+?) mysite.qqq/index.php?s=$1&d=$2&i=$3 [QSA]

Resources