My .htaccess file as below,
DirectoryIndex routing.php
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+Milan_Practice/Milan_Mvc/routing\.php[\s?] [NC]
RewriteRule ^ Milan_Practice/Milan_Mvc/ [L,R=302]
RewriteRule ^Milan_Mvc/?$ Milan_Mvc/routing.php [L,NC]
By Appling above code I got url like below,
http://localhost/Milan_Practice/Milan_Mvc/?name=about
in above,there after "?",data is not in valid format as I want like this,
http://localhost/Milan_Practice/Milan_Mvc/about/
So please give your suggestion with proper ReWriting Rule for above code
ThankYou in Advance !!!
RewriteRule ^([a-z]{2,2})/([a-zA-Z0-9_-]+)$ index.php?name=$1 [QSA]
See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
Related
I have a problem with a rewriterule in my .htaccess, I would like to redirect like this:
www.mywebsite.com/category?p=2
to
www.mywebsite.com/category
where category is variable.
I have my rewrite engine on and other redirects are working fine. This is what what I got so far:
RewriteRule ^/([a-z_\/]*)\?? /$1 [R=301,L]
What is the best way to accomplish this?
Your request looks strange, but anyway, this should do it:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^p=
RewriteRule /?([a-zA-Z0-9]+)/? /$1? [R=301,L]
Use this:
RewriteEngine On
RewriteRule ^category$ /category?p=2 [L]
It will give you the following URL:
www.mywebsite.com/category
I have a .htaccess which reads as follows
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^([a-z0-9\-]+) /index.php?page_name=$1 [L]
I want the link
http://www.solublesilicates.com/our-services when clicked should read as http://www.solublesilicates.com/?page_name=our-services.
Please do help.
RewriteRule ^([a-z0-9\-]+)$ /index.php?page_name=$1 [L, QSA]
Just change it to the above. Should work perfectly.
You have error in your syntax. Your regex should end with $ sign
RewriteRule ^([a-z0-9\-]+)$ /index.php?page_name=$1 [L]
Change the Rewrite Rule to
RewriteRule ^([A-Za-z0-9\-]+) index.php?page_name=$1 [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 have a slight problem.
I have a site that uses these formats for viewing certain PHP documents:
domainname.com/server.php?id=14
domainname.com/changeserver.php?id=14
domainname.com/customize.php?id=14
I would like to make these:
domainname.com/server/14
domainname.com/changeserver/14
domainname.com/customize/14
I also have various URLs such as /index.php and /login.php I would like to clean up.
If someone were to type the original URL, such as /server.php?id=14, I would like it to redirect to it's clean URL.
If anyone can provide me with a config or help me along the way to making one that can do this, it would be greatly appreciated.
To prevent an infinite loop while externally redirecting the ugly url to the clean url and internally rewriting it back to the ugly url, you can use the THE_REQUEST trick.
#External redirect
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /(server|changeserver|customize)\.php\?id=([^&]+)\ HTTP
RewriteRule ^ /%2/%3? [R,L]
#Change above to [R=301,L] once all rules work as expected
#Internal rewrite
RewriteRule ^(server|changeserver|customize)/(.*)$ /$1?id=$2 [L]
You need to rewrite your URLs in .htaccess file.
RewriteEngine On
RewriteRule ^server/(.*)$ server.php?id=$1 [R=301,L]
here is a good guide on URL rewriting
http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
In this case you have to use a 301 Redirect of URLS. Here is an example:
Redirect
www.example.com/a1/articles.php?id=1&name=abc
to
www.example.com/article/1/abc
For this you have to modify the .htaccess file with the following:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.*)&name=(.*)$
RewriteRule ^articles\.php$ /article/%1/%2? [R=301]
RewriteRule ^article/([^-]+)/([^-]+)$ /articles.php?article_id=$1&article_name=$2 [L]
RewriteEngine On
RewriteRule ^server/([A-Za-z0-9-_,()'+]+)?$ server.php?id=$1
RewriteRule ^changeserver/([A-Za-z0-9-_,()'+]+)?$ changeserver.php?id=$1
RewriteRule ^customize/([A-Za-z0-9-_,()'+]+)?$ customize.php?id=$1
To adapt to your code. Here is the answer.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.*)$
RewriteRule ^server\.php$ /server/%1? [R=301]
RewriteRule ^server/([^-]+)$ /server.php?id=$1 [L]
Check the Above code. I think this will help you.
Due to request, every page needs to be prefixed with "index.php"; if the path was first /it, now it needs to be /index.php/it.
I have tried changing base url in settings.php. But it doesnot works.Tried rewriting in .htaccess also. I have tried the following code
RewriteBase /
RewriteCond %{HTTP_HOST} ^http://www.example.com/index.php [NC]
RewriteRule ^(.*)$ http://www.example.com/index.php [L,R=301]
But it doesnot works. Somebody help me please. Thanks in advance..
Make sure you have mod_rewrite enabled and try with this
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)$ http://www.example.com/index.php/$1 [L,R=301]
Remember that the $1 refers to the (.*) you have captured in the URL
You are not using your capture group (.*). You can refer to it using $1
RewriteRule ^(.*)$ http://www.example.com/index.php/$1 [L,R=301]