I want the url:
www.tricore.in/viewdoc.php?did=2&title=mca-sem-2-syllabus
to rewrite like:
http://tricore.in/docs/2/mca-sem-2-syllabus
But whenever I am clicking on any Link from www.tricore.in, the rewriting is not happening.
Below is the code of .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^browse/docs/(.*)/(.*)/(.*)/(.*) docs.php?sortby=$1&filter=$2&page=$3&title=$4
RewriteRule ^browse/categories/doc/(.*)/(.*)/(.*)/(.*) categorydocs.php?sortby=$1&filter=$2&page=$3&title=$4
RewriteRule ^browse/categories/docs/(.*)/(.*)/(.*)/(.*) categorydocs.php?sortby=$1&filter=$2&page=$3&title=$4
RewriteRule ^docs/(.*)/(.*) viewdoc.php?did=$1&title=$2
RewriteRule ^confirmemail/(.*) confirmemail.php?code=$1
RewriteRule ^download/doc/(.*)/(.*) downloaddoc.php?DID=$1&title=$2
RewriteRule ^browse/members/(.*)/(.*)/(.*)/(.*) members.php?sortby=$1&filter=$2&page=$3&title=$4
RewriteRule ^categories/ categories.php
RewriteRule ^members/profile/(.*)/(.*) memberprofile.php?pid=$1&username=$2
RewriteRule ^search/(.*)/(.*)/(.*)/(.*) search.php?searchfor=$1&sortby=$2&page=$3&searchterm=$4
RewriteRule ^syndicate/docs/(.*)/(.*) syndicatedocs.php?filter=$1&title=$2
RewriteRule ^resetpassword/(.*) resetpassword.php?code=$1
RewriteRule ^resendconfirmation/(.*) resendconfirmation.php?userid=$1
</IfModule>
<IfModule mod_security.c>
# Turn off mod_security filtering.
SecFilterEngine Off
# The below probably isn't needed,
# but better safe than sorry.
SecFilterScanPOST Off
</IfModule>
Please tell me, where am I going wrong?
Thank you.
Please use the below rewrite rule. For this specific part.
RewriteRule ^docs/([^/]*)/([^/]*)$ /viewdoc.php?did=$1&title=$2 [L]
Related
How can I make htaccess rewrite the following URL structure:
http://example.com/detail.php?id=polo&categ=wears
to
http://example.com/wears/polo/
I have tried the below code but it didn't work for me.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.+)/(admin|css|fonts|ico|include|js|images|img|products|slide)/(.*)$ $2/$3 [L]
RewriteRule ^(.*)/(.*)/$ detail.php?id=$1&categ=$2
</IfModule>
Your code works for me when I include the trailing slash in the URL.
working -> http://example.com/wears/polo/
not working -> http://example.com/wears/polo
Also, you need to exclude the slash character from the .* expression.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.+)/(admin|css|fonts|ico|include|js|images|img|products|slide)/(.*)$ $2/$3 [L]
RewriteRule ^([^/]*)/([^/]*)/?$ detail.php?id=$1&categ=$2
</IfModule>
Try this
RewriteEngine on
RewriteRule ^/(\w+)/(\w+)$ detail.php?categ=$1&id=$2 [NC,L]
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]
I use .htaccess for Friendly URL, but i have a problem. My subdomain store.domain.com redirect to "/" but, default file is "store.php" and domain.com redirect to "/", default file is "index.php"
i need use if, for example
<If host == 'store.domain.com'>
store rewrite rules
<If host == 'domain.com'>
other rewrite rules different of store
</if>
How i do in .htaccess??
My Htaccess:
IndexIgnore *
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^([a-zA-Z0-9_-]+)$ store.php?page=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ store.php?page=$1
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?page=$1
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?page=$1&action=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?page=$1&action=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ store.php?page=$1&action=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ store.php?page=$1&action=$2
Please try and research your problem a little more before posting a question on Stack Overflow next time. A simple web search of your problem brings up RewriteCond statements. Then you could refer to the Apache mod_rewrite documentation.
This documentation would lead you to results, such as:
RewriteCond %{HTTP_HOST} ^store.example.com$
RewriteRule ^([a-zA-Z0-9_-]+)/?$ store.php?page=$1
I want to show the URL
http://www.example.com/blog/feedback
as
http://www.example.com/feedback
How can I do so using .htaccess?
You will need mod_rewrite to do this.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/feedback$ /blog/feedback
</IfModule>
Have a look here for a tutorial information on mod_rewrite.
EDIT:
If you are trying to move JUST /blog/feedback to /feedback then you will have to first move your base from /app/webroot/blog/ to /app/webroot/, edit all your rules to account for it and then add your new rule. Could be done like so:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /app/webroot/
RewriteRule ^/blog/index\.php$ - [L]
RewriteRule ^/blog/feedback$ /feedback [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /blog /app/webroot/blog/index.php [L]
</IfModule>
NB: This should work, but I'm not at my work station right now so I can't check it :( If anything goes wrong it's probably a typo somewhere - let me know.
I have htaccess file and this is in it:
RewriteEngine On
Options +FollowSymlinks
RewriteBase /project/
RewriteRule ^betNow/$ index.php?action=betNow [L]
RewriteRule ^(.*)/betNow/$ index.php?action=betNow [L]
RewriteRule ^(.*)/betNow/([0-9]+)$ index.php?action=betNow&id=$2 [L]
and it works, when I type localhost/project/betNow/
but I can't figure out last rule
I tried with localhost/project/betNow/4
and localhost/project/betNow/id=4
and that's not working. what am I doing wrong?
Thanks in advance
You have defined your RewriteBase /project/ and your site apparently resides in http://localhost/project/ - so when you call http://localhost/project/betNow/ the request string handed over to the rewrite rules is just betNow/.
Therefor your rules starting with ^(.*)/betNow will not match. You just need:
RewriteRule ^betNow/$ index.php?action=betNow [L]
RewriteRule ^betNow/([0-9]+)$ index.php?action=betNow&id=$2 [L]
And you can use
http://localhost/project/betNow/ --> index.php?action=betNow
http://localhost/project/betNow/4 --> index.php?action=betNow&id=4
Shouldn't the rules be
RewriteEngine On
Options +FollowSymlinks
RewriteBase /project/
RewriteRule ^betNow/$ index.php?action=betNow [L]
RewriteRule ^betNow/([0-9]+)$ index.php?action=betNow&id=$2 [L]
You may need to put a / after both of the ^ characters in the rewrite rules too
Instead of localhost/project/betNow/id=4 try: localhost/project/betNow/id/4
And use:
RewriteRule ^(.*)/betNow/id/([0-9]+)$ index.php?action=betNow&id=$2 [L]