Author |
|
Qmpeltaty
Joined: 06 Feb 2008 Posts: 182 Location: Poland
|
Posted: Tue 13 Jun '17 14:19 Post subject: .htaccess code doesnt work in httpd.conf |
|
|
Hi
Today i was fighting with moving test site version to the production. Developer was preparing the mobile webpage in Angular which requires .htaccess to be placed in DocumetRoot directory :
Code: | DirectoryIndex index.html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^/]+)/?(.*) /mobile/index.html |
As i don't like .htaccess files i proposed to move this configuration to httpd.conf :
Code: | <Location /mobile>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^/]+)/?(.*) /mobile/index.html
</Location>
"DirectoryIndex index.html" line had been removed from Location block |
After placing the .htaccess content to Location block it stopped working as expected. What is the reason ? |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7375 Location: Germany, Next to Hamburg
|
|
Back to top |
|
Qmpeltaty
Joined: 06 Feb 2008 Posts: 182 Location: Poland
|
Posted: Tue 13 Jun '17 15:23 Post subject: |
|
|
I didn't put the Location block to .htacces but opposite, .htaccess file's content to httpd.conf within Location block. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7375 Location: Germany, Next to Hamburg
|
Posted: Tue 13 Jun '17 15:47 Post subject: |
|
|
Then you might try RewriteBase[1]
Code: |
<Location /mobile>
RewriteEngine On
RewriteBase /mobile
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html [QSA,L]
</Location>
|
[1] http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
Quote: | The RewriteBase directive specifies the URL prefix to be used for per-directory (htaccess) RewriteRule directives that substitute a relative path. |
|
|
Back to top |
|
Qmpeltaty
Joined: 06 Feb 2008 Posts: 182 Location: Poland
|
Posted: Tue 13 Jun '17 18:10 Post subject: |
|
|
I tried RewriteBase as well but it didn't work either. |
|
Back to top |
|