my url keys are coming from database , say if my url is abc.com ,i have used a rewrite rule RewriteRule (.*)/(.*)/mcqs/(.*)/(.*)/(.*)\.html mcq.php?mcq_id=$4&page=$5 in this rewrite rule , first four (.*) are coming as url keys from db, but problem is that in address bar am able to add any…
and after writing rewrite rule 404 page was displayed
How many sections?
Is this your table structure?
id
subcat_id
mcq_head
enabled
keywords
keyword_tag
meta_tag
content_tag
page_title
What is the url here:
You said 4 url?
This is only 2:
mcq_id=0&page=0
How does it look:
from 4 to 3 to 2 to 1
LastMitch
Industrious Poster
4,374 posts since Mar 2012
Reputation Points: 149
Solved Threads: 350
Skill Endorsements: 47
@rohanbajaj222
later on home page categories and subcategories have to be changed , but couldnt change the url keys, as those were indexed by google
There's nothing wrong with your URL's.
I think it's your query that fetch the url key is incorrect so that's why it's not displaying the url keys.
LastMitch
Industrious Poster
4,374 posts since Mar 2012
Reputation Points: 149
Solved Threads: 350
Skill Endorsements: 47
@rohanbajaj222
You're query is a JOIN.
Try this I'm not sure it's gonna work because in order to test out URL you have to test it:
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^avatto.com[nc]
RewriteRule ^(.*)$ http://www.avatto.com/$1 [r=301,nc]
//301 Redirect Entire Directory
RedirectMatch 301 www.avatto.com(.*) www.avatto.com/$1
//Change default directory page
DirectoryIndex www.avatto.com
//Rewrite 1
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^([^/]+)/([^/]+)/mcqs/([^/]+)/([^/]+).html$ $mcq.php?mcq_id=$1&page=$2 [NC,R]
//Rewrite 2
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^(.*)/(.*)/mcqs/(.*)/(.*).html$ $mcq.php [R=301,L]
LastMitch
Industrious Poster
4,374 posts since Mar 2012
Reputation Points: 149
Solved Threads: 350
Skill Endorsements: 47
LastMitch
Industrious Poster
4,374 posts since Mar 2012
Reputation Points: 149
Solved Threads: 350
Skill Endorsements: 47
I think i sent wrong query, tht was from another site
I create 2 Rewrite:
//Rewrite 1
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^([^/]+)/([^/]+)/mcqs/([^/]+)/([^/]+).html$ $mcq.php?mcq_id=$1&page=$2 [NC,R]
//Rewrite 2
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^(.*)/(.*)/mcqs/(.*)/(.*).html$ $mcq.php [R=301,L]
I think the issue was I put 2 rewrite that is the same that made the internal error.
This code should be in the htaccess file try this:
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^avatto.com[nc]
RewriteRule ^(.*)$ http://www.avatto.com/$1 [r=301,nc]
//301 Redirect Entire Directory
RedirectMatch 301 www.avatto.com(.*) www.avatto.com/$1
//Change default directory page
DirectoryIndex www.avatto.com
//Rewrite 1
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^([^/]+)/([^/]+)/mcqs/([^/]+)/([^/]+).html$ $mcq.php?mcq_id=$1&page=$2 [NC,R]
then try this if the first one didn't work:
//Rewrite to www
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^avatto.com[nc]
RewriteRule ^(.*)$ http://www.avatto.com/$1 [r=301,nc]
//301 Redirect Entire Directory
RedirectMatch 301 www.avatto.com(.*) www.avatto.com/$1
//Change default directory page
DirectoryIndex www.avatto.com
//Rewrite 2
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^(.*)/(.*)/mcqs/(.*)/(.*).html$ $mcq.php [R=301,L]
LastMitch
Industrious Poster
4,374 posts since Mar 2012
Reputation Points: 149
Solved Threads: 350
Skill Endorsements: 47
I tried both of them very carefully, but none of them is helping out.
Thanx for help
I can't think of another way of doing this. The only way is to really test the Mod Rewrite on your host server.
You already have Data on your database. I don't have a db but you did provide a table but it's much harder for me to duplicate the data and test out the Mod Rewrite.
I know you been trying to make this work but it's much easier to ask your developer(s) to do the Mod Rewrite for you.
LastMitch
Industrious Poster
4,374 posts since Mar 2012
Reputation Points: 149
Solved Threads: 350
Skill Endorsements: 47
LastMitch
Industrious Poster
4,374 posts since Mar 2012
Reputation Points: 149
Solved Threads: 350
Skill Endorsements: 47