Jump to content
This topic contains 36 posts. A summary containing the most significant posts is available

Featured Replies

Posted

Hello.

I have problems with index.php in my urls.

I have the htaccess file and select "Rewrite URLs".

The problem is:

URL in browser -> Destination
mydomain.com/index.php ->  mydomain.com/index.php

mydomain.com/index.php/ ->  mydomain.com

mydomain.com/forum/topic/index.php ->  mydomain.com/

mydomain.com/forum/topic/ -> mydomain.com/forum/topic/

Please, can someone check my text to see if there is something wrong?

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

#Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RedirectMatch ^/forum/(.*?)/?$ /$1


# CUSTOM URLs by DawPi

#Categories & Forums
RewriteRule ^([0-9]+)-([a-zA-Z0-9_-]+).html$ viewforum.php?id=$1 [r=301,nc,l]
RewriteRule ^forum/([0-9]+)-([a-zA-Z0-9_-]+).html$ viewforum.php?id=$1 [r=301,nc,l]

#Profiles
RewriteRule join-club/([0-9]+)-([a-zA-Z0-9_-]+)/profile.html profile.php?id=$1 [r=301,nc,l]

#Topics (second and so on page)
RewriteRule ([0-9]+)-([a-zA-Z0-9_-]+)/([0-9]+)-([a-zA-Z0-9_-]+).html?start=([0-9]+) viewtopic.php?id=$3&st=$5 [r=301,nc,l]

#Topics
RewriteRule ([0-9]+)-([a-zA-Z0-9_-]+)/([0-9]+)-([a-zA-Z0-9_-]+).html viewtopic.php?id=$3 [r=301,nc,l]

# END #


# ----------------------------------------------------------------------
# | ADDED BY ME                                                         |
# ----------------------------------------------------------------------

<Files .htaccess>
Require all denied
</Files>

#Allow conections only bu mydomain.com and alias
RewriteCond %{SERVER_NAME} !^(www\.)?mydomain\.es$
RewriteCond %{SERVER_NAME} !^(www\.)?mydomain2\.com$
RewriteCond %{SERVER_NAME} !^(www\.)?mydomain\.eu$
RewriteCond %{SERVER_NAME} !^(www\.)?mydomain\.info$
RewriteCond %{SERVER_NAME} !^(www\.)?mydomain\.com.es$
RewriteCond %{SERVER_NAME} !^(www\.)?mydomain\.es$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^ - [F]



RewriteCond %{HTTP_HOST} ^www.mydomain2.com [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.mydomain.es/$1 [L,R=301] 
RewriteCond %{HTTP_HOST} ^mydomain2.com [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.mydomain.es/$1 [L,R=301] 
RewriteCond %{HTTP_HOST} ^www.mydomain.eu [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.mydomain.es/$1 [L,R=301] 
RewriteCond %{HTTP_HOST} ^mydomain.eu [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.mydomain.es/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.mydomain.info [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.mydomain.es/$1 [L,R=301] 
RewriteCond %{HTTP_HOST} ^mydomain.info [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.mydomain.es/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.mydomain.com.es [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.mydomain.es/$1 [L,R=301] 
RewriteCond %{HTTP_HOST} ^mydomain.com.es [NC]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.mydomain.es/$1 [L,R=301]


#Clickjacking attack
#Header append X-FRAME-OPTIONS "SAMEORIGIN"

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://mydomain.es/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://mydomain.es$      [NC]
RewriteCond %{HTTP_REFERER} !^http://mydomain2.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://mydomain2.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.es/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mydomain.es$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mydomain2.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mydomain2.com$      [NC]
RewriteCond %{HTTP_REFERER} !^https://mydomain.es/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^https://mydomain.es$      [NC]
RewriteCond %{HTTP_REFERER} !^https://www.mydomain.es/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^https://www.mydomain.es$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp|doc|pdf|mp3|mp4|mov|avi)$ - [F,NC]

# php -- BEGIN cPanel-generated handler, do not edit
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

Many Thanks.

Edited by pequeno

Solved by Matt

Go to solution
  • Author

If I just put this code, it doesn't work either

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

 

  • Author

Any help about this?

  • Community Expert
 

Any help about this?

I have tagged developers on this to take a look at your topic and review.

  • 2 weeks later...
  • Author
 

I have tagged developers on this to take a look at your topic and review.

Any news about this

  • Community Expert

Relooking at this, what exactly is the first one doing?

The topic one would not work, as thats not actually a URL even without rewrites. 

  • Author
 

Relooking at this, what exactly is the first one doing?

The topic one would not work, as thats not actually a URL even without rewrites. 

I will privately send you the URL that corresponds to mydomain.com

I put it this way so as not to reveal my domain.

  • Community Expert

You dont seem to have answered what the first one is doing there. The second, there isnt actually an issue with. 

  • Author

Sorry. I don't know what I have to answer. I am a bit lost with the English language. What do you need to know exactly? 

Redirects should remove index.php and I see that not happening.

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Try and put this at the bottom of your htaccess file

  • Author
 
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Try and put this at the bottom of your htaccess file

Thanks.

It's the code I use, provided by IPS in the ACP, and it doesn't work ... I can't remove index.php from the url

 

Thanks.

It's the code I use, provided by IPS in the ACP, and it doesn't work ... I can't remove index.php from the url

If your site is in forum directory, put in this directory htaccess file with this code

The only way that htaccess code will work is if your hosting provider has mod_rewrite enabled. Have you verified that module is installed and working correctly?

  • Author
 

If your site is in forum directory, put in this directory htaccess file with this code

Forum is in root /

 

The only way that htaccess code will work is if your hosting provider has mod_rewrite enabled. Have you verified that module is installed and working correctly?

Installed and enabled.

This post was recognized by Marc!

Adlago was awarded the badge 'Helpful' and 10 points.

"Thank you for your help"

 

Forum is in root /

Installed and enabled.

Test - add this

RewriteCond %{THE_REQUEST} \ /(.+/)?index\.([^/]+)(\?.*)?\  [NC]
RewriteRule ^(.+/)?index\.([^/]+)$ /%1 [NC,R=301,L]

 

  • Community Expert

Again, you havent actually answered what is happening on the first item when you visit with /index.php

It does sound here like there may be an issue with rewrites on your server

  • Author
 

Again, you havent actually answered what is happening on the first item when you visit with /index.php

It does sound here like there may be an issue with rewrites on your server

Indeed, if I put the address with index.php in the browser, it is not removed and the destination is the same.

 

URL in browser -> Destination
mydomain.com/index.php ->  mydomain.com/index.php

The redirect to remove index.php does not apply in my case.

It only applies if I put a / at the end.

 

mydomain.com/index.php/ ->  mydomain.com

The same happens in topics that have index.php at the end.

 

mydomain.com/forum/topic/index.php ->  mydomain.com/

mydomain.com/forum/topic/ -> mydomain.com/forum/topic/

Thanks @Adlago

 

Test - add this

RewriteCond %{THE_REQUEST} \ /(.+/)?index\.([^/]+)(\?.*)?\  [NC]
RewriteRule ^(.+/)?index\.([^/]+)$ /%1 [NC,R=301,L]

 

I will test.

  • Community Expert

Please let us know if that does not resolve your issue

  • Author
 

Test - add this

RewriteCond %{THE_REQUEST} \ /(.+/)?index\.([^/]+)(\?.*)?\  [NC]
RewriteRule ^(.+/)?index\.([^/]+)$ /%1 [NC,R=301,L]

Works Perfectly! Thanks.

  • Author
 

Works Perfectly! Thanks.

 

 

Please let us know if that does not resolve your issue

 

 

Test - add this

RewriteCond %{THE_REQUEST} \ /(.+/)?index\.([^/]+)(\?.*)?\  [NC]
RewriteRule ^(.+/)?index\.([^/]+)$ /%1 [NC,R=301,L]

 

NOT SOLVED!

Works removing index.php but when I try to upload a embed video or image, I obtain this error:

  Quote

The link could not be embedded because of an unexpected error: forbidden. The CSRF protection key did not match. This may indicate a plugin or theme is out of date. Please contact technical support for more information.

 

  • Community Expert

Please ensure all access details on file are up to date, then we can take a look. Also please ensure you are using only our default htaccess

  • Author
 

Please ensure all access details on file are up to date, then we can take a look. Also please ensure you are using only our default htaccess

Thanks @Marc Stridgen

Please, let me know the IPS IPs for add to firewall whitelist.

  • Community Expert
 

Thanks @Marc Stridgen

Please, let me know the IPS IPs for add to firewall whitelist.

please add 50.28.58.142 and 144.202.11.32 to your firewall whitelist.

  • Author
 

please add 50.28.58.142 and 144.202.11.32 to your firewall whitelist.

Done

  • Author
 

Please ensure all access details on file are up to date, then we can take a look. Also please ensure you are using only our default htaccess

Have you checked It? 

I need to restore my custom htaccess.

Thanks.

Recently Browsing 0

  • No registered users viewing this page.