1

I have a problem accessing some URL with the same starting name of url like these:

RewriteEngine On    # Turn on the rewriting engine

RewriteRule    ^sections?$   sections.php   [NC,L]

RewriteRule    ^sections/?$   sections.php    [NC,L]

RewriteRule    ^sections/([0-9]+)/([a-zA-Z-.]+)/view?$   view_sections.php?id=$1&name=$2   [NC,L]

RewriteRule    ^sections/([0-9]+)/([a-zA-Z-.]+)/view/?$   view_sections.php?id=$1&name=$2    [NC,L]

The first 2 rules work but the the last 2 don't, it just load the sections.php instead of view sections.php. When I use Wamp it works but when I uploaded online it doesn't work. Is it because of the version of php and apache?

My Wamp version:

Apache Version :2.4.9

PHP Version :5.5.12

The hosting version:

Apache version: Apache/2.2.27

PHP version: 5.6.14

If the problem is version issue then what could be the possible solution to make it work in hosting version?

jmattheis
  • 10,494
  • 11
  • 46
  • 58
dmac
  • 53
  • 1
  • 4

1 Answers1

1

Try it like this,

Options -MultiViews

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^sections?$ sections.php [NC]
RewriteRule ^sections/?$ sections.php [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^sections/([0-9]+)/([a-zA-Z-.]+)/view?$ view_sections.php?id=$1&name=$2 [QSA,NC]
RewriteRule ^sections/([0-9]+)/([a-zA-Z-.]+)/view/?$ view_sections.php?id=$1&name=$2 [QSA,NC,L]
Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45
  • Thanks man! it worked! I just inserted this above (Options -MultiViews). By the way can you tell me the use of that line? hehe – dmac Sep 27 '16 at 06:48
  • well it is explained here very well http://stackoverflow.com/questions/25423141/what-exactly-does-the-the-multiviews-options-in-htaccess – Abhishek Gurjar Sep 27 '16 at 06:51
  • If it worked for you can acknowledge this as an answer by clicking right arrow beside the answer. – Abhishek Gurjar Sep 27 '16 at 10:11