Htaccess Redirect gone

Hello everybody,

I am using cakephp 2 and I need to add a 410 code to some pages of my website.
All the URL containing “prix-rue” have to be in 410.

I have added in the 3 htaccess the following code :

RedirectMatch gone prix-rue

But it does not work.
I do not want to do it in the controller beforefilter.

Thanks in advance

Disclaimer: its 1AM so forgive if I overlook something here!

Make sure your .htaccess (well first make sure it starts with a period) is surrounded by the rewrite check, and RewriteEngine is on. You may need a regex wildcard too

<IfModule mod_rewrite.c>
    RewriteEngine On
    RedirectMatch gone ^/prix-rue/.*
</IfModule>

And finally make sure its in your /webroot folder, not in the root folder of your Cake app.

Many thanks for your answer but unfortunately, it does not work. I really do not understand why.

Hope someone could help me.

I precise that I do not want to do the 410 gone in the controller beforefilter because of the googlbot (actualy, it is done in the controller beforefilter). I have lots of urls describing prices of streets (about one million) and parts of these urls were crawled by Google (discovered by sitemaps or not). Google continue to crawl them even if they disappear in the website and in the sitemaps. To prevent from google crawling these urls, and send him a huge signal, the 410 gone has to be done in the htaccess.

Many thanks in advance for your help.

Copy paste the one in the public_html :

< IfModule pagespeed_module >
ModPagespeed on
ModPagespeedRewriteLevel PassThrough
ModPagespeedEnableFilters add_head,fallback_rewrite_css_urls,flatten_css_imports,rewrite_style_attributes_with_url,extend_cache,insert_dns_prefetch,collapse_whitespace,convert_meta_tags,remove_comments,elide_attributes,trim_urls,pedantic,combine_javascript,canonicalize_javascript_libraries,rewrite_javascript,defer_javascript,inline_javascript,rewrite_css,combine_css,move_css_to_head,inline_css,inline_import_to_link,move_css_above_scripts,inline_preview_images,insert_img_dimensions,rewrite_images,recompress_images,convert_jpeg_to_progressive,resize_mobile_images,sprite_images,lazyload_images,local_storage_cache
< /IfModule>

< IfModule mod_headers.c>
Header always set Access-Control-Allow-Headers “Access-Control-Allow-Origin, Origin, Accept,
Accept- Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, x-api-key, X-
Response-Time, X-PINGOTHER, X-CSRF-Token,Authorization”
Header always set Access-Control-Allow-Methods “GET,POST,OPTIONS,DELETE,PUT”

< /IfModule>

< IfModule mod_rewrite.c>
RedirectPermanent /acheter ccc
RedirectPermanent /prix-immobilier/departement-paris xxx
< /IfModule>

< IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [L,R=204]
< /IfModule>

< IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} ^lapporteurdimmo.com$
RewriteRule ^/?$ “xxx” [R=301,L]

RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
< /IfModule>

< IfModule php5_module>
php_flag asp_tags Off
php_flag display_errors Off
php_value max_execution_time 3000000
php_value max_input_time 6000000
php_value max_input_vars 100000000
php_value memory_limit 256000M
php_value post_max_size 128000M
php_value session.gc_maxlifetime 1440000
php_value session.save_path “/var/cpanel/php/sessions/ea-php56”
php_value upload_max_filesize 640000M
php_flag zlib.output_compression On
< /IfModule>
< IfModule lsapi_module>
php_flag asp_tags Off
php_flag display_errors Off
php_value max_execution_time 3000000
php_value max_input_time 6000000
php_value max_input_vars 100000000
php_value memory_limit 256000M
php_value post_max_size 128000M
php_value session.gc_maxlifetime 1440000
php_value session.save_path “/var/cpanel/php/sessions/ea-php56”
php_value upload_max_filesize 640000M
php_flag zlib.output_compression On
< /IfModule>

RewriteCond %{HTTP_HOST} ^lapporteurdimmo.fr$ [OR]
RewriteCond %{HTTP_HOST} ^www.lapporteurdimmo.fr$
RewriteRule ^public_html2$ “xxx” [R=301,L]

< IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
AddType image/x-icon .ico
ExpiresByType image/ico “access plus 1 month”
ExpiresByType image/icon “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 month”
ExpiresByType text/css “access plus 1 year”
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType text/html “access plus 7200 seconds”
ExpiresByType application/xhtml+xml “access plus 1 month”
ExpiresByType application/javascript A2592000
ExpiresByType application/x-javascript “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”
ExpiresByType image/webp “access plus 1 month”
ExpiresByType application/x-font-ttf “access plus 1 month”
ExpiresByType font/ttf “access plus 1 month”
ExpiresByType application/font-woff “access plus 1 month”
ExpiresByType application/x-font-woff “access plus 1 month”
ExpiresByType font/woff “access plus 1 month”
ExpiresByType application/font-woff2 “access plus 1 month”
ExpiresByType font/woff2 “access plus 1 month”
ExpiresByType font/opentype “access plus 1 month”
ExpiresByType font/otf “access plus 1 month”
ExpiresByType application/vnd.ms-fontobject “access plus 1 month”
ExpiresByType font/eot “access plus 1 month”
ExpiresByType font/collection “access plus 1 month”
ExpiresByType video/mp4 “access plus 1 month”
ExpiresByType video/ogg “access plus 1 month”
ExpiresByType video/webm “access plus 1 month”
< /IfModule>

< IfModule mod_headers.c>
< FilesMatch “.(ico|jpe?g|png|gif|swf|css|gz|webp|ttf|svg)"> Header set Cache-Control "max-age=31536000, public" < /FilesMatch> < FilesMatch "\.(js)”>
Header set Cache-Control “max-age=31536000, private”
< /FilesMatch>
< filesMatch “.(html|htm)"> Header set Cache-Control "max-age=7200, public" < /filesMatch> < FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)”>
Header unset Cache-Control
< /FilesMatch>
< /IfModule>

< IfModule mod_rewrite.c>
RewriteRule xxx - [L,R=410]
RewriteRule xxx - [L,R=410]
RewriteRule xxx - [L,R=410]
< /IfModule>

< IfModule mime_module>
AddHandler application/x-httpd-ea-php56___lsphp .php .php5 .phtml
< /IfModule>

Copy paste the one in the app :

< IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
< /IfModule>

< IfModule mod_rewrite.c>
RedirectPermanent /acheter xxx
RedirectPermanent /prix-immobilier/departement-paris xxx
< /IfModule>

< IfModule mod_headers.c>
Header always set Access-Control-Allow-Headers “Access-Control-Allow-Origin, Origin, Accept, Accept- Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, x-api-key, X-Response-Time, X-PINGOTHER, X-CSRF-Token,Authorization”
Header always set Access-Control-Allow-Methods “GET,POST,OPTIONS,DELETE,PUT”
< /IfModule>

< IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [L,R=204]
< /IfModule>

< IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
AddType image/x-icon .ico
ExpiresByType image/ico “access plus 1 month”
ExpiresByType image/icon “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 month”
ExpiresByType text/css “access plus 1 year”
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType text/html “access plus 7200 seconds”
ExpiresByType application/xhtml+xml “access plus 1 month”
ExpiresByType application/javascript A2592000
ExpiresByType application/x-javascript “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”
ExpiresByType image/webp “access plus 1 month”
ExpiresByType application/x-font-ttf “access plus 1 month”
ExpiresByType font/ttf “access plus 1 month”
ExpiresByType application/font-woff “access plus 1 month”
ExpiresByType application/x-font-woff “access plus 1 month”
ExpiresByType font/woff “access plus 1 month”
ExpiresByType application/font-woff2 “access plus 1 month”
ExpiresByType font/woff2 “access plus 1 month”
ExpiresByType font/opentype “access plus 1 month”
ExpiresByType font/otf “access plus 1 month”
ExpiresByType application/vnd.ms-fontobject “access plus 1 month”
ExpiresByType font/eot “access plus 1 month”
ExpiresByType font/collection “access plus 1 month”
ExpiresByType video/mp4 “access plus 1 month”
ExpiresByType video/ogg “access plus 1 month”
ExpiresByType video/webm “access plus 1 month”
< /IfModule>

< IfModule mod_headers.c>
< FilesMatch “.(ico|jpe?g|png|gif|swf|css|gz|webp|ttf|svg)"> Header set Cache-Control "max-age=31536000, public" < /FilesMatch> < FilesMatch "\.(js)”>
Header set Cache-Control “max-age=31536000, private”
< /FilesMatch>
< filesMatch “.(html|htm)"> Header set Cache-Control "max-age=7200, public" < /filesMatch> < FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)”>
Header unset Cache-Control
< /FilesMatch>
< /IfModule>

< IfModule mod_rewrite.c>
RewriteRule xxxx - [L,R=410]
RewriteRule xxx - [L,R=410]
RewriteRule xxx - [L,R=410]
< /IfModule>

Copy paste the one in the webroot :

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

< IfModule mod_rewrite.c>
RedirectPermanent /acheter xxx
RedirectPermanent /prix-immobilier/departement-paris xxximmobilier/paris-75
< /IfModule>

< IfModule mod_headers.c>
Header always set Access-Control-Allow-Headers “Access-Control-Allow-Origin, Origin, Accept, Accept- Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version, x-api-key, X-Response-Time, X-PINGOTHER, X-CSRF-Token,Authorization”
Header always set Access-Control-Allow-Methods “GET,POST,OPTIONS,DELETE,PUT”
< /IfModule>

< IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [L,R=204]
< /IfModule>

< IfModule mod_rewrite.c>
RewriteEngine On
RedirectMatch gone ^prix-immobilier/prix-rue/.*
< /IfModule>

< IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/gif “access plus 1 month”
AddType image/x-icon .ico
ExpiresByType image/ico “access plus 1 month”
ExpiresByType image/icon “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 month”
ExpiresByType text/css “access plus 1 year”
ExpiresByType text/javascript “access plus 1 month”
ExpiresByType text/html “access plus 7200 seconds”
ExpiresByType application/xhtml+xml “access plus 1 month”
ExpiresByType application/javascript A2592000
ExpiresByType application/x-javascript “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”
ExpiresByType image/webp “access plus 1 month”
ExpiresByType application/x-font-ttf “access plus 1 month”
ExpiresByType font/ttf “access plus 1 month”
ExpiresByType application/font-woff “access plus 1 month”
ExpiresByType application/x-font-woff “access plus 1 month”
ExpiresByType font/woff “access plus 1 month”
ExpiresByType application/font-woff2 “access plus 1 month”
ExpiresByType font/woff2 “access plus 1 month”
ExpiresByType font/opentype “access plus 1 month”
ExpiresByType font/otf “access plus 1 month”
ExpiresByType application/vnd.ms-fontobject “access plus 1 month”
ExpiresByType font/eot “access plus 1 month”
ExpiresByType font/collection “access plus 1 month”
ExpiresByType video/mp4 “access plus 1 month”
ExpiresByType video/ogg “access plus 1 month”
ExpiresByType video/webm “access plus 1 month”
< /IfModule>

< IfModule mod_headers.c>
< FilesMatch “.(ico|jpe?g|png|gif|swf|css|gz|webp|ttf|svg)"> Header set Cache-Control "max-age=31536000, public" < /FilesMatch> < FilesMatch "\.(js)”>
Header set Cache-Control “max-age=31536000, private”
< /FilesMatch>
< filesMatch “.(html|htm)"> Header set Cache-Control "max-age=7200, public" < /filesMatch> < FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)”>
Header unset Cache-Control
< /FilesMatch>
< /IfModule>

< IfModule mod_rewrite.c>
RewriteRule xxx - [L,R=410]
RewriteRule xxx - [L,R=410]
RewriteRule xxxx - [L,R=410]
< /IfModule>