Forum Moderators: phranque
RewriteUrl ^schede/([^/]*)/([^/]*).html lista_schede.php?marca_id=$1_$2
Perhaps rewriterules of wordpress are too broad and in conflict with all the RewriteRule I use the site for other scripts outside the wordpress platform.
how can I solve this problem?
all the pages that I try to open (which have their RewriteRule containing the file. htaccess) are sent to the 404 error page of wp.
Yes, but it not work.
My file .htaccess is this:
# -FrontPage-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName [site.com...]
AuthUserFile /home/site/site.com/htdocs/_vti_pvt/service.pwd
AuthGroupFile /home/site/site.com/htdocs/_vti_pvt/service.grp
php_value session.save_path "/tmp"
RewriteEngine On
RewriteRule ^cellulare/([^/]+)/([^/]+)_([^/]+).html show_scheda.php?mod_rewrite=1&scheda_id=$1_$2_$3
RewriteRule ^cellulari/([^/]+)/([^/]+).html lista_schede.php?marca_id=$1_$2
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /news2/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news2/index.php [L]
</IfModule>
Please help me! :)
thank you
You can remove the <IfModule> container unless you want this code to fail silently on servers where mod_rewrite is not installed. Otherwise, they are a waste of byes and CPU resources.
The WP code speed can be improved quite a lot, but let's fix your main problem first...
Jim
# -FrontPage-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName [site.com...]
AuthUserFile /home/site/site.com/htdocs/_vti_pvt/service.pwd
AuthGroupFile /home/site/site.com/htdocs/_vti_pvt/service.grp
php_value session.save_path "/tmp"
RewriteEngine On
RewriteRule ^cellulare/([^/]+)/([^/]+)_([^/]+).html show_scheda.php?mod_rewrite=1&scheda_id=$1_$2_$3 [L]
RewriteRule ^cellulari/([^/]+)/([^/]+).html lista_schede.php?marca_id=$1_$2 [L]
RewriteBase /news2/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news2/index.php [L]
But nothing! all the pages that I try to open are sent to the 404 error page of wp.
Help me.
thank you :)
Also exclude that rule's target as well, so that the file- and directory- exists checks are not done twice.
See several other minor corrections, clean-ups, and optimizations.
# -FrontPage-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
#
Order deny,allow
#
<Limit GET POST>
Allow from all
</Limit>
#
<LimitExcept GET POST>
Deny from all
</Limit>
#
AuthName http://www.example.com
AuthUserFile /home/site/example.com/htdocs/_vti_pvt/service.pwd
AuthGroupFile /home/site/example.com/htdocs/_vti_pvt/service.grp
#
php_value session.save_path "/tmp"
#
RewriteEngine on
#
RewriteRule ^cellulare/([^/]+)/([^/]+)_([^/]+)\.html show_scheda.php?mod_rewrite=1&scheda_id=$1_$2_$3 [L]
RewriteRule ^cellulari/([^/]+)/([^/]+)\.html lista_schede.php?marca_id=$1_$2 [L]
#
RewriteBase /news2/
#
RewriteCond %{REQUEST_URI} !^/news2/index\.php$
RewriteCond %{REQUEST_URI} !^/cellular[ei]/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news2/index.php [L]
Jim
If you'd like to exclude requests for "/cellulare/" and "/cellulari/" from being rewritten to WP, then that is correct. Are you sure you understood what it means? If not, see the Regular-Expressions tutorial cited in our Apache Forum Charter. :)
You'l have t be more specific on what the remaining problems are. "It does not work" doesn't give any useful information. Completely flush (delete) your browser cache, then test, then report what URL-paths you tested, the results you expected, and the results you actually got. Include relevant entries from your server error log and server access log.
Jim
Looking at this again, the WP exclusion needs to account for the preceding rewrites to "/show_scheda.php" and "/lista_schede.php" :
#
RewriteCond %{REQUEST_URI} !^/(news2/index¦show_scheda¦lista_schede)\.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /news2/index.php [L]
Jim
I corrected the pipe characters.
But still nothing. When I log on the main page and click on product links show_scheda I get back the 404 error page of wordpress instead of the product brochure. To explain it is as if the rewrite wordpress overwrites rewrtite of show_scheda and lista_scheda.
Thank you for your help. I hope not abandon me. :)
bye
David
Do *not* feel free to change anything about mod_rewrite code syntax as described in the Apache documentation; Unlike scripting languages that allow programmers to 'style' directives in almost any way they choose, mod_rewrite requires *exact* syntax, and no such variations will be recognized.
A request for the URL-path "index.php" will *not* match a pattern of ^index\.Php$" because the case of the first "p" is different.
Jim
but nothing yet. :(
When I log on the main page and click on product links show_scheda I get back the 404 error page of wordpress instead of the product brochure.
I did not think it was so difficult to solve this problem :(
thank you
Some exact information is needed:
In simple terms, the patterns in the first rule-set are not matching because your on-page link is to "/show_scheda" instead of to "/cellulare". So you may ignore those two lines of code for now, or even comment them out.
The pattern in the second rule-set is apparently not matching -- and therefore, not excluding requests for "/show_scheda" URLs from being rewritten to WordPress, where they fail with a 404. So, the task is to discover why that pattern does not match... The pattern is specifying the wrong URL-paths, but in what way? -- What are the correct URL-paths?
Be very sure you took action on the warning above:
Replace all broken pipe "¦" characters in the lines above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
Jim
http://www.example.com/news2/news-cellulari/nuovo-iphone-apple.html (example of post in wordpress with this structure permalink:
/%category%/%postname%.html )
# On the server, what is the exact filepath to the file or script used to serve that /news2 URL request?
home/sitex/example.com/htdocs/news2
# When you hover over a "/cellare link, what is the URL-path shown in the browser address bar?
http://www.example.com/cellulare/1234/Nokia_N76.html
(example of a link of cellulare, with this rewrite rule:
RewriteRule ^cellulare/([^/]+)/([^/]+)_([^/]+)\.html show_scheda.php?mod_rewrite=1&scheda_id=$1_$2_$3 [L]
the file show_scheda.php is located in the home/sitex/example.com/htdocs
# When you get a 404 on clicking that link, what is the entry in your server error log?
when for example I click on
http://www.example.com/cellulare/1234/Nokia_N76.html
or link
http://www.example.com/cellulari/10/Nokia.html
(this link use the rewriterule:
RewriteRule ^cellulari/([^/]+)/([^/]+)\.html lista_schede.php?marca_id=$1_$2 [L]
and the file lista_schede.php is located on:
home/sitex/example.com/htdocs
# Be very sure you took action on the warning above:
Replace all broken pipe "¦" characters in the lines above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
I have exactly the correct pipe characters :)
Thanks for your patience
[edited by: jdMorgan at 2:11 pm (utc) on Jan. 25, 2010]
[edit reason] example.com [/edit]
Try this code, as a temporary file for testing:
Options +FollowSymLinks -MultiViews
#
# -FrontPage-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
#
Order deny,allow
#
<Limit GET POST>
Allow from all
</Limit>
#
<LimitExcept GET POST>
Deny from all
</Limit>
#
AuthName http://www.example.com
AuthUserFile /home/site/example.com/htdocs/_vti_pvt/service.pwd
AuthGroupFile /home/site/example.com/htdocs/_vti_pvt/service.grp
#
php_value session.save_path "/tmp"
#
RewriteEngine on
#
RewriteRule ^cellulare/([^/]+)/([^/]+)_([^/]+)\.html show_scheda.php?mod_rewrite=1&scheda_id=$1_$2_$3 [L]
RewriteRule ^cellulari/([^/]+)/([^/]+)\.html lista_schede.php?marca_id=$1_$2 [L]
#
# Removed RewriteBase
#
RewriteCond %{REQUEST_URI} !^/news2/index\.php$
# The following three rewriteconds should no longer be needed, but this is for testing
RewriteCond %{REQUEST_URI} !^/show_scheda\.php$
RewriteCond %{REQUEST_URI} !^/lista_schede\.php$
RewriteCond %{REQUEST_URI} !^/cellular[ei]/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^news2/. news2/index.php [L]
If you get a 404 or any other server error, please include the relevant entry from your server error log.
If you still have problems, please copy my three-test list above, and add comments to each test description about what actually happened.
Completely flush (delete) your browser cache before testing after you upload any modified code.
Jim
I'm sorry for the headache. But the solution you found.
Heartfelt thanks
I have a small request.
If I wanted to install wordpress in the future in the root directory.
What should only change the htaccess file?
thanks
David :)
Take "news2" out of the right side of the last RewriteRule if you want to keep "news2" as a "virtual subdirectory," or take "news2" out of both sides of the last RewriteRule if you do not want to keep that virtual subdirectory.
Jim
Options +FollowSymLinks -MultiViews
#
# -FrontPage-
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
#
Order deny,allow
#
<Limit GET POST>
Allow from all
</Limit>
#
<LimitExcept GET POST>
Deny from all
</Limit>
#
AuthName http://www.example.com
AuthUserFile /home/site/example.com/htdocs/_vti_pvt/service.pwd
AuthGroupFile /home/site/example.com/htdocs/_vti_pvt/service.grp
#
php_value session.save_path "/tmp"
#
RewriteEngine on
#
RewriteRule ^cellulare/([^/]+)/([^/]+)_([^/]+)\.html show_scheda.php?mod_rewrite=1&scheda_id=$1_$2_$3 [L]
RewriteRule ^cellulari/([^/]+)/([^/]+)\.html lista_schede.php?marca_id=$1_$2 [L]
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . news2/index.php [L]
And everything works!
There are no errors. and returns all pages correctly!
is important to add this item at top:
Options +FollowSymLinks -MultiViews
Thank you very very much :)
sorry for all :D
The first RewriteCond on the last rule should be
RewriteCond %{REQUEST_URI} !^/news2/index\.php$
On some sites, adding this one line can noticeably speed up access to the site.
And as mentioned here or in other threads on this subject, you may wish to exclude other "well-known" requests which *you know* should not be rewritten to WordPress. Each of these exclusions will give a performance improvement -- some small, but certainly not negligible. Replace the RewriteCond above with something like
RewriteCond !((\.(gif¦jpe?g¦png¦ico¦css¦js))¦^/news2/index\.php¦^/robots\.txt¦/sitemap\.xml)$
Once you've tested that, you may wish to add domain and resource canonicalization redirects as discussed in many other threads here to prevent duplicate-content issues and to "focus your branding."
Jim
I found this topic really interesting since I have the exact same problem with WP.
I didn't understand how to exclude WP rewrite rules to apply just custom rules first.
Can I post my .htaccess code in these topic or should I start a new one?
Anyway, thanks a lot for your efforts in helping us, your time is really appreciated.
rewriterule ^([^-]+)-([^&]+)\.html$ /page.php?id=$1&id=$2 [L]
rewritecond %{http_host} ^myURL.com [nc]
rewriterule ^(.*)$ http://www.myURL.com/$1 [r=301,nc] # BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress <IfModule mod_rewrite.c>
# BEGIN WordPress
#
RewriteEngine on
#
# Unless you have set a different RewriteBase preceding this point,
# you may delete or comment-out the following RewriteBase directive
# RewriteBase /
#
# if this request is for "/" or has already been rewritten to WP
RewriteCond $1 ^(index\.php)?$ [OR]
# or if request is for image, css, or js file
RewriteCond $1 \.(gif|jpg|ico|css|js)$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ - [S=1]
# else rewrite the request to WP
RewriteRule . /index.php [L]
#
rewriterule ^([^-]+)-([^&]+)\.html$ /scenes.php?id=$1&id=$2 [L]
rewritecond %{http_host} ^myURL.com [nc]
rewriterule ^(.*)$ ht\tp://www.myURL.com/$1 [r=301,nc]
# END wordpress
</IfModule>