1.11M Members

url rewriting

LastMitch
Deleted Member
 
0
 

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

 
0
 

yes , this is the table structure for mcqs.
In this url
http://www.avatto.com/gate/aptitude/mcqs/reasoning/complete-the-series/104/1.html
I said there are 4 url keys one each for
1. home page category -eg gate
2. home page subcategory-eg aptitude
3. mcq head category-eg reasoning
4. mcq subheading -eg complete-the-series

later on home page categories and subcategories have to be changed , but couldnt change the url keys, as those were indexed by google

LastMitch
Deleted Member
 
0
 

@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.

 
0
 

hum......., am using this query

$QUERY="select tbl_mcq_title.id, tbl_mcq_title.mcq_title, tbl_category_master.category_name, tbl_subcategory_master.subcat_name, tbl_mcq_master.mcq_head, tbl_category_master.keywords as cat_key, tbl_subcategory_master.keywords as subcat_key, tbl_mcq_master.keywords as head_key, tbl_mcq_title.keywords as title_key from tbl_mcq_title left join tbl_mcq_master on tbl_mcq_title.mcq_m_id = tbl_mcq_master.id join tbl_subcategory_master on tbl_subcategory_master.id = tbl_mcq_master.subcat_id join tbl_category_master on tbl_category_master.id = tbl_subcategory_master.cat_id WHERE tbl_subcategory_master.id=$subcat_id order by tbl_mcq_master.mcq_head, tbl_mcq_title.mcq_title"

for displaying
http://www.avatto.com/gate/computer-science/mcqslist/10.html

LastMitch
Deleted Member
 
0
 

@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]
 
0
 

it didnt worked, i got internal server error

LastMitch
Deleted Member
 
0
 

What error?

 
0
 

error message was internal server error

 
0
 

I think i sent wrong query, tht was from another site

LastMitch
Deleted Member
 
0
 

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]
 
0
 

I tried both of them very carefully, but none of them is helping out.
Thanx for help

LastMitch
Deleted Member
 
0
 

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.

 
0
 

i have another problem also, if i insert some static text in my urls from browser , they are not redirected to their original url , nor do they show some error, do we solve this problem from htaccess or chenges in db are required

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: