I recently changed my hosting. The old server had php 5.3 and the newer has php 5.6. This change in host is one step towards making my website compatible with php 7.
However I have come across an issue with htaccess redirect.
My htaccess file looks like below
DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^company/([0-9]+)/?$ company.php?company_id=$1 [L]
So when I go to page with url mydomain.com/admin/company/92
I don't seem to get the redirected URL as required i.e. mydomain.com/admin/company.php?company_id=92
This is some of the output from printing $_SERVER
[REDIRECT_SCRIPT_URL] => /admin/company/92/
[SCRIPT_FILENAME] => /htdocs/myproj/admin/company.php
[REDIRECT_URL] => /admin/company.php/92/
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /admin/company/92/
[SCRIPT_NAME] => /admin/company.php
[STATUS] => 200
[ORIG_PATH_INFO] => /92/
[ORIG_PATH_TRANSLATED] => /htdocs/myproj/admin/company.php
[PHP_SELF] => /admin/company.php
[argv] => Array
(
)
[argc] => 0
)
I have got php 5.3 on my local and the same code works fine on my local. How do I resolve this issue?
^companythe^sticks it to the start of the string. So anything beforecompanywill make it fail to match. You could change it toRewriteRule /company/([0-9]+)/?$ /company.php?company_id=$1 [L]for example