【问题标题】:Mod Rewrite in apache 2.2 centos 6.5Apache 2.2 centos 6.5 中的 Mod 重写
【发布时间】:2015-02-23 03:49:18
【问题描述】:

我正在尝试在 htaccess 中编写友好的 seo url(重写规则),但出现错误。

当我检查 mod_rewrite 安装为静态时。请在下方查看

core_module (static)
 authn_file_module (static)
 authn_default_module (static)
 authz_host_module (static)
 authz_groupfile_module (static)
 authz_user_module (static)
 authz_default_module (static)
 auth_basic_module (static)
 include_module (static)
 filter_module (static)
 deflate_module (static)
 log_config_module (static)
 logio_module (static)
 env_module (static)
 expires_module (static)
 headers_module (static)
 unique_id_module (static)
 setenvif_module (static)
 version_module (static)
 proxy_module (static)
 proxy_connect_module (static)
 proxy_ftp_module (static)
 proxy_http_module (static)
 proxy_scgi_module (static)
 proxy_ajp_module (static)
 proxy_balancer_module (static)
 ssl_module (static)
 mpm_prefork_module (static)
 http_module (static)
 mime_module (static)
 status_module (static)
 autoindex_module (static)
 asis_module (static)
 info_module (static)
 suexec_module (static)
 cgi_module (static)
 negotiation_module (static)
 dir_module (static)
 actions_module (static)
 userdir_module (static)
 alias_module (static)
 rewrite_module (static)
 so_module (static)
 bwlimited_module (shared)
 suphp_module (shared)
 security2_module (shared)
 pagespeed_module (shared)

下面是我的htaccess代码

   <IfModule mod_rewrite.c>
RewriteEngine On
DirectoryIndex /raaga/splash/index.php

#REWRITE RULES
#---------------------

#RULE RAAGA_REGISTER 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/images/
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^register /raaga/register.php [L]


ErrorDocument 404 /raaga/oops_404.php
ErrorDocument 500 /raaga/oops_500.php
</IfModule>

AddType application/octet-stream ts
AddType application/x-web-app-manifest+json webapp

请帮助我做错了什么。上面的代码在该文件夹中的另一台服务器上工作,我们在 public_html 本身中有项目,但这里是 public_html/raaga 所以我添加了 /raaga/register.php 而不是 /register.php

服务器,

我认为 htaccess 中没有错误,应该是 httpd.conf,我必须在 httpd.conf 文件中进行更改

谢谢

塔尼盖维兰

【问题讨论】:

  • 您遇到的错误是什么
  • @Thanigaivelan i am getting error 你发布了所有这些信息,却忘记了最重要的一个:(,你在#RULE RAAGA_INDEX 的最后一个 RewriteRule 也被注释掉了,但是你的 2 个条件在之间不是,这可能是导致问题的原因。
  • 您能否添加预期结果的示例。因为我不明白你想用这些 ${Lang:$1} 或 ${profile_tab:$3} 做什么你想在重写的链接中找到它们? (例如:${Lang:en}

标签: apache .htaccess


【解决方案1】:

试试看:

<IfModule mod_rewrite.c>
RewriteEngine On
DirectoryIndex /raaga/splash/index.php

#REWRITE RULES
#---------------------

# Not for real file or directory or /images/ directory or .gif...
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR] 
RewriteCond %{REQUEST_URI} ^/images/ [NC,OR]
RewriteCond %{REQUEST_URI} \.(gif|jpe?g|png)$ [NC]
RewriteRule ^ - [L]

#RULE RAAGA_LABLE_ALBUM_DETAILS 
RewriteRule ^label/([a-zA-Z]*)/(albums|songs)/([^/]+)-([a-zA-Z0-9_-]*)/([^/]+)-([a-zA-Z0-9_-]*) /raaga/lable_home.php?l=$1&tab=$2&lbl=$4&mid=$6 [QSA]

#RULE RAAGA_LABLE_ 
RewriteRule ^label/([a-zA-Z]*)/([^/]+)-([a-zA-Z0-9_-]*) /raaga/lable_home.php?l=$1&lbl=$3 [QSA]

#RULE RAAGA_LABLE_ALBUM 
RewriteRule ^label/([a-zA-Z]*)/(albums|songs)/([^/]+)-([a-zA-Z0-9_-]*) /raaga/lable_home.php?l=$1&tab=$2&lbl=$4 [QSA]

#RULE RAAGA_MOVIEDETAIL_PLAY 
RewriteRule ^([a-zA-Z0-9_-]*)/album/([^/]+)-([a-zA-Z0-9_-]*)-play /raaga/albumpage.php?l=$1&mid=$3&autoplay=play [L]

#RULE RAAGA_MOVIEDETAIL 
RewriteRule ^([a-zA-Z0-9_-]*)/album/([^/]+)-([a-zA-Z0-9_-]*) /raaga/albumpage.php?l=$1&mid=$3 [L]

#RULE RAAGA_PROFILE_FAV_ALBUM_PLAY 
RewriteRule ^profile/([^/]+)-([a-zA-Z0-9_-]*)/([a-zA-Z]*)/albums/([^/]+)-([a-zA-Z0-9_-]*)-play /raaga/profile.php?uid=$2&ty=$3&page=album&mid=$5&autoplay=play [L]


ErrorDocument 404 /raaga/oops_404.php
ErrorDocument 500 /raaga/oops_500.php
</IfModule>

AddType application/octet-stream ts
AddType application/x-web-app-manifest+json webapp

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 2012-09-09
    相关资源
    最近更新 更多