XF 2.1 How to simplify URL of home page and other pages when shared? (Remove 'index' in URL)

tomwood

Member
Hello,

When I copy/paste my website URL from the browser address bar to share it on social media, the clickable link looks like this:
Code:
https://agentsofdisrupt.com/index.php

How can I make it look like this:
Code:
https://agentsofdisrupt.com

When I copy/paste from the browser address bar to share the URL of a specific page, the clickable link looks like this:
Code:
https://agentsofdisrupt.com/index.php?pages/where_to_find/

How can I make it look like this:
Code:
https://agentsofdisrupt.com/where_to_find/

I want to put that last one as the website URL in my social media profiles. Right now, it returns a 404 - URL not found error. The long address looks clunky.

Thanks!
 

tomwood

Member
Checking the box to Use full friendly URLs fixed the main website URL so it looks like this:
Code:
https://agentsofdisrupt.com/

but the page URL
Code:
https://agentsofdisrupt.com/where_to_find/
returns a 404 not found. (Edit: this is with the route filter ON)

If I leave the friendly URL off and implement a route filter like this:

Find route: pages/where_to_find

Replace with: where_to_find

I still get index.php? in the URL:
Code:
https://agentsofdisrupt.com/index.php?where_to_find/

Is it safe to show the contents of my .htaccess file here? I think it's the standard one from Xenforo.
 
Last edited:

Brogan

XenForo moderator
Staff member
Rename the htaccess.txt file on the server to .htaccess.

None of the pages other than the index page are working, so either the .htaccess file is missing, or the server doesn't support it.
 

tomwood

Member
It's already named .htaccess. It's an Apache server at A2 Hosting.

Yeah, the entire site is now broken.

(Edit: removed image)
 
Last edited:

Brogan

XenForo moderator
Staff member
Check the contents of the .htaccess file.

It should look like this:
Code:
#    Mod_security can interfere with uploading of content such as attachments. If you
#    cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
#    SecFilterEngine Off
#    SecFilterScanPOST Off
#</IfModule>

ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default

<IfModule mod_rewrite.c>
    RewriteEngine On

    #    If you are having problems with the rewrite rules, remove the "#" from the
    #    line that begins "RewriteBase" below. You will also have to change the path
    #    of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    #    This line may be needed to workaround HTTP Basic auth issues when using PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>

If it is, then disable the FURLs and contact your host and get them to configure the server to support it.
 

tomwood

Member
I got it to work by adding the code in Brogan's post above to the existing code in the .htaccess file and adding the route filter. The existing code is necessary to implement the SSL certificate, according to A2 Hosting support.

However, now all the image links in this page are broken:


In the code for the page, the code for each image is like this:

Code:
<img src="styles/default/images/175x280_coolhunter_red_streaks.png" />

Edit: Disabling the route filter doesn't solve the broken path to the images.

So I'm guessing the FURL is somehow breaking the path to the image. How do I fix that?
 
Last edited:

Brogan

XenForo moderator
Staff member
It should be: /styles/default/images/175x280_coolhunter_red_streaks.png

Note the / at the start.

However, if you embedding images, you would typically use the absolute URL, not a relative one.
 
Top