I just setup a Backdrop site on NameCheap. I would like to eliminate query script (?q=) from the URL. The NameCheap hosting is shared so there is very limited access to the server. I tried putting random characters in the .htaccess file but that didn't seem to change the server behavior which led me to believe the use of the .htaccess file was not enabled.

I wrote to NameCheap about the problem. They replied: "According to our check, the URL structure is not related to our server-side settings. The URL structure may be fixed by changing the permalink structure settings in the script of your CMS. We suggest you contact the CMS developer to assist you with changing the permalink structure.". Does the "permalink structure" have any relevance to clean urls?

Any thoughts would be appreciated.

Dale

Accepted answer

Hmm.. I don't know enough about servers - maybe someone else can help here.

It seems like the .htaccess file is not being read by the server (you said you put random characters there, and did not get a 500 error). You are seeing an .htaccess file in the root directory of your installation, right? And it also contains:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico 
RewriteRule ^ index.php [L]

right?

Also check out this article. It may be that you are not on an Apache server and/or mod_rewrite is not enabled. You can always check the type of server by going to admin/reports/status

Try also uncommenting $base_url = 'http://www.example.com'; in your settings.php file.

I don't know what they meant by "permalink structure".  

 

Comments

Have you checked if clean URLs are enabled in your site - at:

admin/config/urls/settings

Yes I did check and it say they are not enabled.

Sorry I forgot to mention that.

Dale

Have you tried enabling them there? Does that solve your problem?

When I run the clean url test it says it failed and "Clean URLs cannot be enabled". Clicking save configuration doesn't seem to do anything.

Can you check Reports -> Recent log messages  for the specific error? It should be logged under the key "system"

Hmm.. I don't know enough about servers - maybe someone else can help here.

It seems like the .htaccess file is not being read by the server (you said you put random characters there, and did not get a 500 error). You are seeing an .htaccess file in the root directory of your installation, right? And it also contains:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico 
RewriteRule ^ index.php [L]

right?

Also check out this article. It may be that you are not on an Apache server and/or mod_rewrite is not enabled. You can always check the type of server by going to admin/reports/status

Try also uncommenting $base_url = 'http://www.example.com'; in your settings.php file.

I don't know what they meant by "permalink structure".  

 

.htaccess had not been altered since install so I added the lines you suggested and it didn't change anything.

Uncomplementing and adding the base_url didn't change anything either.

It is an Apache server.

I had looked at the Backdrop clean url page and the Drupal page it links too. They seem to say the .htaccess file is my option. I will write back to NameCheap and ask if the server is setup to read the .htaccess file.

Thank you very much for giving me your time.

Clean URLs started to work just after I made my previous reply.

I believe adding:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico 
RewriteRule ^ index.php [L]

to the .htaccess file fixed the clean URLs. It must have taken the server a while to re-read it?

I had uncommenting $base_url = 'http://www.example.com'; in your settings.php but changed it back after not seeing results.

Thank you very  much for showing me how to fix the clean url problem.

Great! Glad it helped.

By the way, those lines I pasted were extracted from the default .htaccess file that is installed with Backdrop - so, it's strange that they were not there. Perhaps they were taken off by the server itself, or maybe an old htaccess file existed there already and was not overwritten when you install Backdrop. I would check it to make sure it contains all the code needed for a Backdrop installation. You can download the backdrop codebase from git and compare it to what you have in the server.  

I uploaded the compressed backdrop file from my home computer and decompressed it on the NameCheap server. When I looked into the .htaccess file all that was in it was "RewriteOptions inherit". After reading your note above I looked at the .htaccess file on my home computer (the source) and it has a lot in it but not RewriteOptions inherit. Interesting, I don't know what happened but if someone else has this problem I hope it gives them another clue about what to look for.

Thanks