合并 .htaccess 文档 - Wordpress 和 aMember

发布于 2024-11-29 04:38:42 字数 1283 浏览 3 评论 0原文

如何合并这两个 .htaccess 文件?我一直触发 500 个错误。

  • 每个版本都可以单独使用,效果非常好。
  • Amember .htaccess (1st) 保护访问我认为应该首先实施。
  • 干净的 URL 需要 WordPress .htaccess(第二个)。

htaccess 1)

########### AMEMBER START #####################
Options +FollowSymLinks
RewriteEngine On

## allow access for product #12        
RewriteCond %{HTTP_COOKIE} amember_nr=([a-zA-Z0-9]+)
RewriteCond /home/www/changed.tld/amember/data/new_rewrite/%1-12 -f 
RewriteRule ^(.*)$ - [L]

## if user is not authorized, redirect to login page
# BrowserMatch "MSIE" force-no-vary
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^(.*)$ http://changed.tld/amember/plugins/protect/new_rewrite/login.php?v=-12&url=%{REQUEST_URI}?%{QUERY_STRING} [L,R]
RewriteRule ^(.*)$ http://changed.tld/amember/plugins/protect/new_rewrite/login.php?v=-12&url=%{REQUEST_URI} [L,R]
########### AMEMBER FINISH ####################

htaccess 2)

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

AddType application/octet-stream .pdf

How would one go about merging these two .htaccess files? I keep triggering 500 errors.

  • Each version works beautifully on its own.
  • Amember .htaccess (1st) protects access I believe should be implemented first.
  • Wordpress .htaccess (2nd) is needed for clean urls.

htaccess 1)

########### AMEMBER START #####################
Options +FollowSymLinks
RewriteEngine On

## allow access for product #12        
RewriteCond %{HTTP_COOKIE} amember_nr=([a-zA-Z0-9]+)
RewriteCond /home/www/changed.tld/amember/data/new_rewrite/%1-12 -f 
RewriteRule ^(.*)$ - [L]

## if user is not authorized, redirect to login page
# BrowserMatch "MSIE" force-no-vary
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^(.*)$ http://changed.tld/amember/plugins/protect/new_rewrite/login.php?v=-12&url=%{REQUEST_URI}?%{QUERY_STRING} [L,R]
RewriteRule ^(.*)$ http://changed.tld/amember/plugins/protect/new_rewrite/login.php?v=-12&url=%{REQUEST_URI} [L,R]
########### AMEMBER FINISH ####################

htaccess 2)

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

AddType application/octet-stream .pdf

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

岁月蹉跎了容颜 2024-12-06 04:38:42

我的想法是倒退的。技巧是首先“重写”wp 链接,然后运行 ​​amember Protect .htaccess。以下是最终为我工作的内容。特别注意 WP 重写的最后一行中缺少的 [L]。

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

# END WordPress

########### AMEMBER START #####################
Options +FollowSymLinks
RewriteEngine On

## allow access for product #12        
RewriteCond %{HTTP_COOKIE} amember_nr=([a-zA-Z0-9]+)
RewriteCond /home/www/changed.tld/amember/data/new_rewrite/%1-12 -f 
RewriteRule ^(.*)$ - [L]

## if user is not authorized, redirect to login page
# BrowserMatch "MSIE" force-no-vary
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^(.*)$ http://changed.tld/amember/plugins/protect/new_rewrite/login.php?v=-12&url=%{REQUEST_URI}?%{QUERY_STRING} [L,R]
RewriteRule ^(.*)$ http://changed.tld/amember/plugins/protect/new_rewrite/login.php?v=-12&url=%{REQUEST_URI} [L,R]
########### AMEMBER FINISH ####################

My thinking was backwards. Trick was to 'rewrite' the wp links first and then run the amember protect .htaccess next. Below is what ended up working for me. Specifically note the missing [L] in the last line of the WP rewrite.

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

# END WordPress

########### AMEMBER START #####################
Options +FollowSymLinks
RewriteEngine On

## allow access for product #12        
RewriteCond %{HTTP_COOKIE} amember_nr=([a-zA-Z0-9]+)
RewriteCond /home/www/changed.tld/amember/data/new_rewrite/%1-12 -f 
RewriteRule ^(.*)$ - [L]

## if user is not authorized, redirect to login page
# BrowserMatch "MSIE" force-no-vary
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^(.*)$ http://changed.tld/amember/plugins/protect/new_rewrite/login.php?v=-12&url=%{REQUEST_URI}?%{QUERY_STRING} [L,R]
RewriteRule ^(.*)$ http://changed.tld/amember/plugins/protect/new_rewrite/login.php?v=-12&url=%{REQUEST_URI} [L,R]
########### AMEMBER FINISH ####################
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文