Need help, It is basic Mod-Rewrite. But i am confused
My current URL:
http://example.com/category.php?fn=accounting-tax
Want look like this:
http://example.com/category/accounting-tax
Only Apache Mod-Rewrite, No PHP please
Update:
Is it possible without PHP?
Thank you
Add this to your .htaccess in your web root /
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} (^|&)fn=(.*)(&|$)
RewriteRule ^category\.php$ category/%2 [NC,L]
Assuming, you meant
/category.php?fn=accounting-tax should take you to /category/accounting-tax
without showing up on the address bar. If you want an external redirect use [R=301,NC,L] instead.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^category/([a-z0-9\-]+)/item/?$ /category.php?id=$1
</IfModule>
Related
I wanted change this joomla link
http://www.asbhtechsolutions.com/component/search/?searchphrase=all&searchword=simple%20program%20for%20java
to
http://www.asbhtechsolutions.com/search/simple-program-for-java
How can I do this?
If you don't want to write your own router for the search component, the simplest way is to add a redirect to your .htaccess file.
I don't know about your joomla version, but i checked in joomla 1.5.26,
Just got to the joomla/components/com_search/controller.php
and Search the function search(), at the bottom of this function you find the line that call the url with JRoute class.
$this->setRedirect(JRoute::_('index.php'.$uri->toString(array('query', 'fragment')), false));
now dig something your self to change according to your need, or read some documentation on Joomla JRoute, don't forget to change according to your Joomla Version.. Hope this help you..
if you don't have enough experience with .htaccess try renaming htaccess.txt file to .htaccess. It's contained in your root directory of the Joomla installation.
Oh.. I've never seen a question about .htaccess like this before, it's not easy. I do not know if the code below would work. Just give a try to test this in your .htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/search/([a-z0-9-_]+)/?$
RewriteRule ^(.*) /component/search/?searchphrase=all&searchword=%1
RewriteCond %{REQUEST_URI} ^/search/([a-z0-9-_]+)/([a-z0-9-_]+)/?$
RewriteRule ^(.*) /component/search/?searchphrase=all&searchword=%1\%20%2
RewriteCond %{REQUEST_URI} ^/search/([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)/?$
RewriteRule ^(.*) /component/search/?searchphrase=all&searchword=%1\%20%2\%20%3
RewriteCond %{REQUEST_URI} ^/search/([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)/([a-z0-9-_]+)/?$
RewriteRule ^(.*) /component/search/?searchphrase=all&searchword=%1\%20%2\%20%3\%20%4
I'd like to rewrite
www.site.com/a/b/?param1=one¶m2=two
in
www.site.com/c/d/e/?param1=one¶m2=two.
Where www.site.com/a/b does not exists. I tried with
RewriteEngine on
Options +FollowSymLinks
RewriteRule ^a/b/(.*)$ www.site.com/c/d/e/$1 [QSA,L]
What's wrong with it?
Try this one:
RewriteEngine on
Options +FollowSymLinks
RewriteRule ^/a/b/(.*)$ /c/d/e/$1 [QSA,L]
There is no need for adding the incompleate domain. If you want that the users visit a second domain you have to add the R option and the protocol. For a redirect to a second domain try this:
RewriteRule ^/a/b/(.*)$ http://www.site.com/c/d/e/$1 [R,QSA,L]
Is there any way i can use RewriteRule to show these links:
/articles_history.php
/articles_geography.php
as
/articles/history.html
/articles/geography.html
I created a .htacesss file on my root directory and would like to know if the above is possible by placing some kind of code in the .htaccess file.
RewriteEngine On
RewriteRule /articles/(.+)\.html /articles_$1.php [L,QSA]
Yes it is.
See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
In addition to RewriteRule, you also need to usually turn the rewrite engine on by the RewriteEngine directive.
Try this in your .htaccess:
RewriteEngine on
RewriteRule ^article/([^/]+)\.html$ articles_$1.php [L]
And for an arbitrary input:
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)\.html$ $1_$2.php [L]
How can I go about redirecting my old URLs which would have been: http:// blah.com/some/post/name
to the new URLs which would be: http:// blah.com/new/some/post/name
Is this even possible?
I don't want to simply redirect any requests for the blah.com domain to blah.com/new
I want to make sure the subpath is still attached to the redirect
it should be possible.
Try to put this in your .htaccess file:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/some\/?
RewriteRule (.*) /new/$1 [R=301]
</IfModule>
Try it out and let me know - I haven't had time to test it very thoroughly.
I have used rewrite url module but I am not able to redirect to the target page and
I am getting error as:
The requested URL /old.html was not found on this server.
Here is my code:
<IfModule mod_rewrite>
RewriteEngine On
RewriteRule ^old.html$ new.html [R]
</IfModule>
Is AllowOverride set to All in your httpd.conf? Like this:
AllowOverride All
Also, your .htaccess should inlcude the L modifier for the last rule, and if you really want to redirect permanently, R=301:
RewriteEngine On
RewriteRule ^old.html$ /new.html [R=301,L]
You need to escape the . in .html with a \
So its:
RewriteEngine on
RewriteRule ^old\.html$ new.html [R]
Try also setting the RewriteBase to / like so
RewriteBase /
I've also tried this code for
RewriteEngine On
RewriteBase /
RewriteRule ^old.html$ /new.html [R=301,L]
error as The requested URL /old.html was not found on this server.
How to check the load module in apache server?