0

working on local setup . Found this problem while rewriting URL to look good I have department , category and products list ....when i click on one of the department the url is rewritten from

Project /index.php?departmentId=1 to
Project/deptname-d1

And it displays the associated categories with tat department the twist is when one of the category is selected server throws object not found The selected URL was not found on server the link on referring page seems to be wrong or outdated The URL before rewriting would be

Project/index.php?departmentId=1&CategoryId=2

The required format of url is Project /deptname-d1/catname-c2 The regex in htacess is something like this Options +FollowSymLinks RewriteEngine on RewriteBase /project RewriteCond %{THE_REQUEST} ^GET.*/index.(php|html?)\ HTTP RewriteRule ^(.)index.(php|html?)$ $1 [R=301,L] #rewrite rules for department RewriteRule ^.?-d([0-9]+)/page-([0-9]+)/?$ index.php? DepartmentId=$1&Page=$2[L] RewriteRule ^.?-d([0-9]+)/?$ index.php?DepartmentId=$1[L] #rules for category RewriteRule ^.-d([0-9]+)/^.-c([0-9]+)/page-([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2&Page=$3[L] RewriteRule ^.-d([0-9]+)/^.c([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2 [L] #rewrite rules for product Rewriterule ^.?-p([0-9]+)/?$ index.php?productId=$1

Before rewriting the following were the urls localhost/project/ for front page localhost/project/index.php?DepartmentId=x for department front page localhost/project/index.php?DepartmentId=x&page=zfor department pag localhost/project/index.php?DepartmentId=x&CategoryId=y for category front page localhost/project/index.php?DepartmentId=xCategoryId=y&page=z for category pages localhost /project/ProductId=Q These are the input Urls which are to be rewritten in the following form Localhost/project/ for front page localhost/project/department-name-dx/ for department front page localhost/project/department-name-dx/page-z/ for department pages localhost/project/department-name-dx/category-name-cy/ for category front localhost/project/department-name-dx/category-name-cy/page-z for category pages

Please note tat department and product related regex are working fine only the category page is acting weird can someone explain wats going wrong 
4
  • Fix your rules in .htaccess, and add this: RewriteRule Project/deptname-d(\d+)/?$ /index.php?departmentId=$1 [L] Commented Nov 4, 2013 at 14:56
  • No luck ..i tried your method now server throws error 500 Commented Nov 4, 2013 at 15:56
  • It shouldn't, please post fixed .htaccess Commented Nov 4, 2013 at 16:15
  • updated the post please have a look at it ...and suggest somethin Commented Nov 4, 2013 at 16:52

1 Answer 1

0

Your regex is wrong. You cannot place ^ in the middle of your regex. Try this:

RewriteEngine On

RewriteRule ^.*?-d([0-9]+)/.*?-c([0-9]+)/page-([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2&Page=$3 [L,QSA]
RewriteRule ^.*?-d([0-9]+)/.*?c([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2 [L,QSA]

I suggest you to provide all the input URLs in your question.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah jus now have look at it and sorry it was upted via mobile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.