существующий файл .htaccess
RewriteEngine on
RewriteBase/
# if not https, redirect
RewriteCond %{SERVER_PORT} !^443$
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# parse the subdomain as a variable we can access
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} !^app
RewriteCond %{HTTP_HOST} ^([^\.]+)\.([^\.]+)\.([^\.]+)$
RewriteRule ^(.*)$ /$1?sub=%1
# ignore any .cfm|.html|.asp|.ico files and certain directories
RewriteRule ^(php|images|css|js|xyz|(.*)\.php|(.*)\.html|(.*)\.asp|(.*)\.ico)($|/) - [L]
# map all requests to the 'path' get variable in index.cfm
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [L,QSA]
=======.htaccess игнорировать определенные каталоги, но передать подобласть
currently its doing this:
https://hello.domain.com --> https://hello.domain.com/index.php?sub=hello
https://hello.domain.com/dir1/15 --> https://hello.domain.com/index.php?path=dir1/15&sub=hello
https://hello.domain.com/index.php --> https://hello.domain.com/index.php
https://hello.domain.com/images/logo.png --> https://hello.domain.com/images/logo.png
what needs to happen:
1. https://hello.domain.com/index.php --> https://hello.domain.com/index.php?sub=hello
(в настоящее время к югу = привет это не добавляется)
2. https://hello.domain.com/process/generate.php --> https://hello.domain.com/process/generate.php?sub=hello
(«/ process» следует игнорировать, но «sub = hello» еще нужно передать)
В основном все, что мне нужно, дополняет правила, чтобы убедиться, что # 1 & # 2 также работают. Никаких изменений существующих правил не должно происходить.
Заранее благодарен!
Это почти все. Но теперь я получаю это: https://hello.domain.com/index.php?sub=hello&sub=hello – artknight
Это исправить эту проблему, но теперь что-то еще не работает. Предполагается, что hello.domain.com/about/a.php будет hello.domain.com/index.php?sub=hello&path=about/a.php, но ему не хватает "path = about/a.php" – artknight
ok , намного лучше, но все же не совсем. Два условия не выполняются. 1. Любая папка, которая не указана в правиле игнорирования, должна перейти в «index.php», например: https://hello.domain.com/about/a.php должно быть https: //hello.domain .com/index.php? sub = hello & path = about/a.php – artknight