Is there a htaccess rewrite rule wildcard? - apache

I'd like to rewrite and redirect project/issues/(some_stuff_here) to i/(same_stuff_here) . I've been fumbling around with htaccess for a while now and I haven't gotten anywhere. I'd appreciate it if someone could write out the code I need (with some helpful comments explaining why something goes where it does). Thanks! :)
EDIT: I should have mentioned that I also need i/(same_stuff_here) to display everything on project/issues/(some_stuff_here).

You can use this rule in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteRule ^project/issues/(.*)$ /i/$1 [L,NC]

Related

Writing htaccess rewrite rules

I need help in making this htaccess rewrite rule
Suppose I have this url http://test.com/new.php?code=6789767897879&channel=1432
I need to make it http://test.com/live/6789767897879/1432.m3u8 where code and channel number are variable
So far I tried this with no luck but it keeps giving me no page found.
RewriteEngine On
RewriteBase /
RewriteRule ^/live/(.*)/(.*)?$ /new.php?code=$1&channel=$2
I am sorry but I am a beginner. Any effort is appreciated. Thanks again
Could you please try following, written and tested with your shown samples. Please make sure you clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteRule ^live/([^/]*)/([^.]*)\.m3u8/?$ new.php?code=$1&channel=$2 [NC,L]

assistance to with rewrite rule

I want URL to look like www.example.com/chat/91 but really the page is www.example.com/room.php?id=91 I searched online for apache rewrite example but I didn't see any examples in this format to use,
Use this RewriteRule in your .htaccess file:
RewriteEngine On
RewriteRule ^chat/([^/]*)$ /room.php?id=$1 [L]
Make sure you clear your cache before testing this.

Apache .htaccess redirect URL directories containing parameters

Sorry to be the asker of yet another tedious mod_rewrite question but after having made no progress in the last few hours, I thought it was time to ask ;)
I am trying to redirect URLs like these:
/some/thing?a=1 --> http://something-else.com/blah
/some/thing?a=1&b=whatever --> http://something-else.com/blah2
No need to keep the param values - the new URL will be hard-coded for each one I have to be redirected.
Have tried a few different things from other posts but with no joy so I am back to square one so any suggestions would be most welcome.
Thanks! :)
You can use the following rule-set:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^a=1$
RewriteRule /some/thing http://something-else.com/blah [L]
This is indeed quite a common question, and people tend to overlook the QUERY_STRING variable. Have you tried it before?
This is what I used in the end:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(a=1&b=whatever)$
RewriteRule /some/thing http://something-else.com/blah2 [L,R=301]
I was adding the rules at the bottom rather than directly below the "RewriteEngine On" which was preventing it from working.
This solution does still append the params to http://something-else.com/blah2 which isn't exactly what I wanted but it will do.

Rewriting url using mod-rewrite and apache

I'm trying to add some rewriting on my site, but it seems to not work, I'm using apache and .htaccess.
The code in my .htaccess file is:
RewriteEngine On
RewriteRule ^/?os_framework/?$ /os_framework/index.php?module=home [L,NC,QSA,PT]
This should send http://localhost/os_framework/ to http://localhost/os_framework/index.php?module=home
But it seems not to.
Any help would be appreciated.
In advance, thanks
Edit: Fixed the above, shouldn't have the os_framework/ in the search pattern, however now i cant get this one to work:
RewriteRule ^/(.[^/]*)/?$ /os_framework/index.php?module=$1 [L,NC,QSA,PT]
And what is wrong with
RewriteRule ^(.[^/]*)/?$ /os_framework/index.php?module=$1 [L,NC,QSA,PT]
Why does that throw a error 500? it should work
Try this:
RewriteEngine On
RewriteRule ^os_framework/?$ os_framework/index.php?module=home [L,NC,QSA]

apache url rewrite on .htaccess

I need to figure out the code on my .htaccess for the following.
Redirect url http://www.mydomain.com/somekw to http://www.mydomain.com/differentkw
also http://www.mydomain.com/somekw?sort=rating&order=ASC to http://www.mydomain.com/differentkw
I have read up about .htaccess but I have very little skills, hopefully someone can help me out.
This should work:
RewriteEngine on
RewriteRule somekw differentkw [L]
That will change any instance of somekw of differentkw. The GET values will stay there.
Just make sure you have mod_rewrite enabled.