Rewrite Rule does not allow me to access my index.php domain

On my page, when I write url domain.com/abc, it uses htaccess RewriteRule (located below) and opens the company-profile.php page, displaying the ABC profile. ABC EXAMPLE. THIS CAN BE SEVERAL

However, even I have a domain.com/index.php file, when I write only domain.com and press enter, it brings me to the company-profile.php page where it should show the index.php file

My question is: how can I fix this?

RewriteEngine On RewriteRule ^([a-z0-9]+)?$ /domain.com/company-profile.php?cid=$1 [NC,L] 
+4
source share
3 answers

Something like this maybe?

 RewriteCond %{REQUEST_URI} !^/$ RewriteCond %{REQUEST_URI} !^/index.(php|html?) RewriteRule ^(.*)$ profile/company-profile.php?cid=$1 [NC,L] 
0
source

The first part of your RewriteRule matches any combination of letters and numbers and passes it to your /domain.com/profile/company-profile.php script. You should be more specific on a RewriteRule , i.e.:

 RewriteEngine On RewriteRule ^/profile/([a-z0-9]+)?$ /domain.com/profile/company-profile.php?cid=$1 [NC,L] 

The above will correspond to queries starting with /profile/ , so for example there will be /profile/martinbean .

0
source

Is apache your web server. If so, you should first check the loaded apache modules to see if the rewrite module is loaded. If not, try adding this line:

 LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so 

to apache configuration files. Then try restarting the web server to see if rewirte rules work.

0
source

Source: https://habr.com/ru/post/1382104/


All Articles