Reputation: 42380
I have a project that lives at the following domain:
http://www.example.com/PROJECT/
within project, there are three subpages, which have pages structured like this:
http://www.example.com/PROJECT/first-subpage.php?Page_ID=12345
http://www.example.com/PROJECT/second-subpage.php?Page_ID=12345
http://www.example.com/PROJECT/third-subpage.php?Page_ID=12345
I am trying to write multiple Mod Rewrite rules for each of these, so that I can have-urls of the following style redirect like so:
http://www.example.com/PROJECT/first-section/12345/some-other-text-here
>>
http://www.example.com/PROJECT/first-subpage.php?Page_ID=12345
Here is what I have, but I have not been able to get the matches to get picked up, according to this .htaccess tester
here is my current .htaccess
file:
RewriteEngine On
RewriteBase /PROJECT/
<filesMatch "^(/first-section/.*)">
Options +FollowSymlinks
RewriteRule ^/(.*)$/(.*)$/(.*)$ /first-subpage.php?page_ID=$2
</filesMatch>
<filesMatch "^(/second-section/.*)">
Options +FollowSymlinks
RewriteRule ^/(.*)$/(.*)$/(.*)$ /second-subpage.php?page_ID=$2
</filesMatch>
<filesMatch "^(/third-section/.*)">
Options +FollowSymlinks
RewriteRule ^/(.*)$/(.*)$/(.*)$ /third-subpage.php?page_ID=$2
</filesMatch>
how can I get these rules to match the urls properly?
Upvotes: 2
Views: 279
Reputation: 2632
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^PROJECT/first-section/([^/]+)/([^/]+) /PROJECT/first-subpage.php?Page_ID=$1 [NC]
RewriteRule ^PROJECT/second-section/([^/]+)/([^/]+) /PROJECT/second-subpage.php?Page_ID=$1 [NC]
RewriteRule ^PROJECT/third-section/([^/]+)/([^/]+) /PROJECT/third-subpage.php?Page_ID=$1 [NC]
Note : Please double check the var name as it's case sensitive , your variable in the question was Page_ID
, and it's page_ID
in your .htaccess
code .
Upvotes: 2