私はカスタムのPHP、mySQL CMSを構築しました。ニュース記事へのリンクは、このとして表示:htaccessとカスタムphp CMSのかなりのURL
https://www.example.com/news/post.php/?p=example-article-slug
しかし、私は彼らがこのよう表示する:
https://www.example.com/example-article-slug
htacessファイルの作品に以下のコードを他のすべての機能を破ります404と301のリダイレクトなどのhtaccessで何か案は?
RewriteEngine On
RewriteRule ^([^/]*)$ /news/post.php/?p=$1 [L]
それはこのURLであなたを残します:https://www.example.com/example-article-slug
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ news/post.php/?p=$1 [QSA,L]
ここに私の完全なhtaccessファイルは、あなたがこれを使用することができます...
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
Options -Indexes
ErrorDocument 201 /404.php
ErrorDocument 401 /404.php
ErrorDocument 404 /404.php
ErrorDocument 402 /404.php
ErrorDocument 505 /404.php
ErrorDocument 500 /404.php
RewriteEngine On
RewriteBase/
Redirect 301 /oldpage.php http://www.example.com/
#Check for www
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{THE_REQUEST} \ /(.*/|)(?:index\.php)?\?id=([^\s&]+) [NC]
RewriteRule^/%1%2? [R=301,L,NE]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ news/post.php/?p=$1 [QSA,L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ news/category/?cat=$1 [QSA,L]
'news/category /?...'の最後のルールは、それ以前のルールが 'news/post.php'以外のすべてのファイル/ディレクトリを送信しているので、決して起動しません。 – anubhava