I'm try to rewrite my url
http://www.domain.com/live/randomword
it should go rewrite to
http://www.domain.com/live/?cat=randomword
here are my tests:
RewriteRule ^live/(.*)$ /live/?cat=$1
RewriteRule ^live/(.*)$ live/?cat=$1
and all i have in the htaccess file is:
RewriteEngine on
You should try to add a RewriteBase / to your .htaccess and to suffix your rule with a [L] to say it's last rewrite rule ending with something like that:
RewriteEngine on
RewriteBase /
RewriteRule ^live/(.*)$ live/index.php?cat=$1 [L]
If this still doesn't work be sure to check that mod_rewrite is enabled
also you can do a [R,L] instead of [L] to see the redirection in the url and so have more info on what's going own.
hope this help
Have this code in your .htaccess file:
Options -MultiViews +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^live/(.*)$ /live/?cat=$1 [L,NC]
in rewrite rule the file name or extension in missing?
write rule like,
RewriteRule ^live/([a-zA-Z0-9_-]+)$ /viewcategory.php?cat=$1
Related
I am trying to rewrite a specific PHP file GET parameter but cant seem to get things to work.
I want to rewrite http://www.example.com/meeting.php?ref=y0fpjXrrGP so it is http://www.example.com/meeting/y0fpjXrrGP
What am I mising on the below? Note I am using WordPress so adding to the existing htaccess file.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^meeting/(.*)$ meeting.php?ref=$1
</IfModule>
# END WordPress
Options -Indexes
Adding RewriteRule ^meeting/(.*)$ meeting.php?ref=$1 does not seem to work at all.
Just use this in your .htaccess file:
RewriteEngine On
RewriteRule ^meeting/([^/]*)$ /meeting.php?ref=$1 [L]
It will leave you with the URL: http://www.example.com/meeting/y0fpjXrrGP
Make sure you clear your cache when testing this.
You don't need to add that to .htaccess, if your URL is inside your Wordpress, you need to add them to the rewrite URL
Check this:
How to create custom URL routes?
Hope it helps.
Target is to create friendly URL, and I got stuck here.
My link below:
Turpināt lasīt..
My .htaccess
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^blog/([0-9]+)/?$ blog.php?id=$1
No problems in configuration, simple rewrite rules work. What's wrong here?
Thanks
Ok try this code:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+blog\.php\?id=([^\s&]+) [NC]
RewriteRule ^ /blog/%1? [R=301,L]
RewriteRule ^blog/([0-9]+)/?$ /blog.php?id=$1 [L,QSA]
I want rewrite my link
/svlist/sv_image.php?ip=109.73.77.38&port=35115&game=cs2d
to
/svlist/cs2d/109.73.77.38:35115.png
I'm really new on that stuff.
RewriteRule ^(svlist)/([^.]*)\/([0-9]+):([^.]*)\.png$ $1/sv_image.php?ip=$3&port=$4&game=$2 [L,NC]
I tried this one and failed..
Try:
RewriteRule ^svlist/([^/]+)/([0-9.]+):([0-9]+)\.png$ /svlist/sv_image?ip=$2&port=$3&game=$1 [L,QSA]
If you want to rewrite /svlist/$var1/$var2:$var3.png into /svlist/sv_image.php?ip=$var2&port=$var3&game=$var1 you could check this:
# once per .htaccess file
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^svlist/([a-z0-9-_]+)/([0-9\.]*):([0-9]*).png /svlist/sv_image.php?ip=$2&port=$3&game=$1 [L,NC]
But if the URLs that you want to rewrite are /svlist/sv_image.php?ip=$var1&port=$var2&game=$var3 into /svlist/$var3/$var1:$var2.png then try to check these rewrite condition and rule:
RewriteCond %{QUERY_STRING} ip=([0-9\.]*)&port=([0-9]*)&game=([a-z0-9-_]+)
RewriteRule ^svlist/sv_image.php /svlist/%3/%1:%2.png [L,NC]
i want rewrite it with a .htaccess i have this url:
../index.php?page=details&id=123456
like this:
../detail/123456
but I do not really know how to do this. Could you help me to rewrite this url?
or give me a simple example that I can understand how it works
RewriteRule ^(.*)/([0-9]+)$ index.php?page=$1&id=$2&%{QUERY_STRING}
The first (.*) selects any string, e.g. "details". ([0-9]+) catches a number, in your case "123456"
Finally
&%{QUERY_STRING}
ensures, that additional parameters are added to your backendscript, too.
This should work:
RewriteEngine On
RewriteRule ^detail/([^/]*)$ /index.php?page=details&id=$1 [L]
Here is an example I use for my webpage when it's in a subdirectory.
# "learn/degree/index.php?d=mathematics" shows as "learn/degree/mathematics"
RewriteRule ^learn/degree/([a-zA-Z_-]+)$ learn/degree/index.php?d=$1
To complete it, remember to write at the beginning of the page this:
RewriteBase /
RewriteEngine On
Here's the 'full' .htaccess I use in my page to give you some idea.
#Redirect any www. to the page without it. Helps to keep user logged.
RewriteBase /
RewriteEngine On
rewriteCond %{HTTP_HOST} ^www.newfutureuniversity.org [NC]
rewriteRule ^(.*)$ http://newfutureuniversity.org/$1 [R=301,L]
Options +Indexes
Options +FollowSymlinks
# Finally working. Rewrite the user so "/student/Username" will internally be "/student/?user=Username"
RewriteRule ^student/([a-zA-Z0-9_-]+)$ student/index.php?user=$1
# Rewrite the disciplines so "learn/degree/1" will internally be "learn/degree/index.php?dis=1"
RewriteRule ^learn/degree/([1-4])$ learn/degree/index.php?dis=$1
# Rewrite the degrees so "learn/degree/mathematics" will internally be "learn/degree/index.php?d=mathematics"
RewriteRule ^learn/degree/([a-zA-Z_-]+)$ learn/degree/index.php?d=$1
# Rewrite the degrees so "learn/subject/2/5/7" will internally be "learn/subject/index.php?class=2&div=5§ion=7"
RewriteRule ^learn/subject/([0-9])$ learn/subject/index.php?class=$1
RewriteRule ^learn/subject/([0-9])/([0-9])$ learn/subject/index.php?class=$1&div=$2
RewriteRule ^learn/subject/([0-9])/([0-9])/([0-9])$ learn/subject/index.php?class=$1&div=$2§ion=$3
You have to make the links to ../detail/123456, then the script interpretes it internally as ../index.php?page=details&id=123456. If you don't want this, then you are looking for a redirect.
Try this
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymlinks
# RewriteBase / add this if necessery, commented intentionally
RewriteRule ^detail/([0-9]+)$ index.php?page=details&id=$2
</IfModule>
I need a rewrite rule to rewrite the following:
www.abc.com/page/xyz to www.abc.com/xyz
remove **"page"** from url
I think it's more like this:
RewriteBase /
RewriteRule ^(.*)$ page/$1 [L]
If I understand what you're trying to do.
Like so:
RewriteBase /
RewriteRule ^page(/.*)?$ $1 [L]
If you only want to redirect page/xyz then you can use:
RewriteEngine on
RewriteRule ^/page/xyz$ /xyz [L]
If you want to redirect anything within the page directory, then use:
RewriteEngine on
RewriteRule ^/page(/.*$)$ $1 [L]