localhost/visvabharati/archive.html/type/notice
this is my url.I want it to rewrite as
localhost/visvabharati/archive.php?type=notice
Please help me how would be the htaccess
currently using
AddHandler x-mapp-php5 .php
Options +FollowSymLinks
RewriteEngine on
#RewriteBase /
DirectoryIndex index.php?url_key=index [T=application/x-httpd-php,L]
RewriteRule ^([^/]*).html$ /index.php?url_key=$1 [T=application/x-httpd-php,L]
RewriteRule ^([^/]*).html-([^/]*)$ /index.php?url_key=$1&id=$2 [T=application/x-httpd-php,L]
But its giving 500.
Please Help me sort it out
Regards
This code here will do it for one page.
RewriteRule ^localhost/visvabharati/archive.html/(.+)/(.+) localhost/visvabharati/archive.php?$1=$2
If you need to do this for multiple pages, this should work.
RewriteRule ^localhost/visvabharati/(.+).html/(.+)/(.+) localhost/visvabharati/$1.php?$2=$3
Assuming visvabharati is a directory.
Place this in /visvabharati/.htaccess:
RewriteEngine on
RewriteBase /visvabharati/
RewriteRule ^([^.]+)\.html/([^/]+)/([^/]+)/?$ $1.php?$2=$3 [L,QSA,NC]
Also you need to remove all the code shown in your question.
Related
I'm trying to redirect a folder to a file.
I want to redirect:
www.mysite.com/category/customername
AND
www.mysite.com/category/customername/
TO
www.mysite.com/category.php?customer=customername
This is working, but "customer" become "customername.php" and not "customer"
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^category/(.*)$ category.php?customer=$1 [L]
How could i remove ".php" via .htaccess?
Thank you!
You can use:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^category/([\s\w-]+)/?$ category.php?customer=$1 [L,NC,QSA]
Thank you anubhava, i have do a dynamic rule:
RewriteRule ^(.+[^/])/(\w+)/?$ $1.php?customer=$2 [L]
Tested for
www.mysite.com/category_1/customer AND
www.mysite.com/category_1/customer/
www.mysite.com/category_2/customer AND
www.mysite.com/category_2/customer/
www.mysite.com/category_X/customer AND
www.mysite.com/category_X/customer/
Bye
I now have:
Order deny,allow
Options +FollowSymlinks
RewriteEngine on
DirectoryIndex index.php
RewriteRule ^en/newsevents$ ?action=setLang&lang=eng&menuid=6 [L,QSA]
It loads my texts but thiks it must look in the /en folder.
This does work, but changes the url from localhost/en/newsevents to localhost/name/?action=setLang&lang=eng&menuid=6
I want that it still remains localhost/en/newsevents
RewriteRule ^en/newsevents$ `http://localhost/name/?action=setLang&lang=eng&menuid=6 [L,QSA]`
Just do this:
RewriteRule ^(en/newsevents)$ $1?action=setLang&lang=eng&menuid=6 [QSA,L]
You need to use passthrough
RewriteRule ^en/newsevents$ ?action=setLang&lang=eng&menuid=6 [PT,L,QSA]
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 to turn a url in the url friendly.
my url:
http://www.builtbydoctors.com/qrcode/index.php?id=93
and i want this url friendly:
http://www.builtbydoctors.com/qrcode/**title**/93
the title changes depending on the id.
my problem is in the htaccess file in the creation of the regular expression. there have:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index/([a-z0-9-]+)/([0-9]+)/?$ /index.php?id=$2&nome=$1 [NC]
</IfModule>
I know that the problem is in the htaccess file, can help me solve this problem in regular expression?
Your rule will work for url
http://www.builtbydoctors.com/index/title/93
If you want use it for your example then you should change your rule to
RewriteRule ^qrcode/([a-z0-9-]+)/([0-9]+)/?$ /index.php?id=$2&nome=$1 [NC]
Try to do so
<IfModule mod_rewrite.c>
RewriteEngine On
# Using this you can tell Rewrite to have a base url
RewriteBase /qrcode
RewriteRule ^([a-z0-9-]+)/([0-9]+)/?$ index.php?id=$2&nome=$1 [NC,L,QSA]
</IfModule>
Hope that works!
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>