简体   繁体   English

URL重写-.htaccess apache

[英]URL Rewriting - .htaccess apache

So I am using a script from the internet and i get the following URL generated: 因此,我正在使用来自互联网的脚本,并且生成了以下URL:

http://mydomain.net/pages/92/Marketing-Idea

And I want it to look the following: 我希望它看起来如下:

http://mydomain.net/marketing-idea

I'm noob with the URL rewriting, so after looking up for some tutorials I've tired the following rule / condition but it doesn't work at all: 我对URL重写不感兴趣,因此在查找了一些教程之后,我已经厌倦了以下规则/条件,但它根本不起作用:

RewriteRule ^/([A-Za-z0-9-]+)/?$    /pages/$1/$2    [NC,L]    # pages

Any one that could help me? 有谁可以帮助我吗? I'm desperate here and can't get this crap to work!! 我在这里很绝望,不能让这个垃圾工作!

This is the entire .htaccess file as it is: 这是整个.htaccess文件,如下所示:

#SetEnv APPLICATION_ENV development

Options -Indexes
Options +FollowSymLinks 
DirectoryIndex index.php index.html
<ifModule mod_rewrite.c>    
RewriteEngine on    
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php [L,QSA]
RewriteRule ^([0-9]+)/([a-z0-9-]+)/?$ /pages/$1/$2 [NC,L]
</ifModule>
<ifModule mod_expires.c>    
ExpiresActive On    
ExpiresDefault "access plus 1 seconds"  
ExpiresByType text/html "access plus 1 seconds" 
ExpiresByType image/gif "access plus 2592000 seconds"   
ExpiresByType image/jpeg "access plus 2592000 seconds"  
ExpiresByType image/png "access plus 2592000 seconds"   
ExpiresByType text/css "access plus 604800 seconds" 
ExpiresByType text/javascript "access plus 216000 seconds"  
ExpiresByType application/x-javascript "access plus 216000 seconds"
</ifModule>
<ifModule mod_deflate.c>
<filesmatch "\.(js|css|html|jpg|png|gif|eot|woff|ttf|svg)$">
    SetOutputFilter DEFLATE
</filesmatch>
</ifModule>

<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak|cache)$">
Order Allow,Deny
Deny from all
</FilesMatch>

Best Regards, Dorian 最好的问候,多利安

Try this rule in your DOCUMENT_ROOT/.htaccess file: 在您的DOCUMENT_ROOT/.htaccess文件中尝试以下规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/([a-z0-9-]+)/?$ /pages/$1/$2 [NC,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM