漂亮的网址图像使用htaccess

时间:2018-04-09 11:59:09

标签: php regex .htaccess

我想学习htaccess编码。我成功地完成了我的网址,但是为什么我的图片网址规则不起作用。经过几次尝试,我还没有解决它。

我的真实网址:

http://localhost/project/osclass/oc-content/uploads/img-post/117/156.jpg

我想要的是什么:

http://localhost/project/osclass/oc-content/uploads/img-post/117/156-some-pretty-title-here.jpg

htaccess的

php_value upload_max_filesize 100M
php_value post_max_size 100M

Options -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project/osclass/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /project/osclass/index.php [L]


RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule project/osclass/oc-content/uploads/img-post/([0-9]+)\/([0-9]+)-(.*)+\.([a-z]+)$ project/osclass/oc-content/uploads/img-post/$1/$2.$4 [L,NC]

</IfModule>

示例http://localhost/project/osclass/oc-content/uploads/img-post/117/156-asdasda-asdasd-asdasd.jpg&gt;&gt;找不到

我测试了我的正则表达式并且它有效,但为什么我的htaccess不起作用?

正则表达式:https://regexr.com/3niu5

我是否想念我的正则表达式?

0 个答案:

没有答案